@import url('https://fonts.googleapis.com/css?family=Audiowide&display=swap');

:root {
  /* set some defaults incase of JS failure */
  --playmatrix-width-count: 16;
  --playmatrix-height-count: 20;
  --playmatrix-cell-edge-length:50px;
  --shape-creator-matrix-length:4;
  --shape-creator-cell-colour:#b71eff;
}

* {
  box-sizing: border-box;
}

html {
  background-color: black;
  color: white;
  height: 100vh;
}
header{
  height: 5vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

header * {
  margin: 0.5vh;
}

h1{
  font-size: 6vh;
  font-weight: bolder;
  font-family: monospace;
  margin: 0.5vh 1vh 0.5vh 1vh;
}

header button{
  background-color: #cebabae8;
  height: 3vh;
  width: 10vh;
  border-style: none;
  font-size: 1.5vh;
}
button{
text-transform: capitalize;
}
header button:hover{
  background-size: 800% 500%;
  background-image: repeating-linear-gradient(45deg, violet, indigo, blue, green, orange, red, violet);
  color:#cebabae8;
  animation: pulse 2s linear infinite;
}
header button span {
  margin: 0;
}
.hiscores{
  text-transform: uppercase;
  overflow: hidden;
  height: 3vh;
  position: relative;
  margin:0;
  line-height: 1.23;
}
/* credit for soft fading- https://codepen.io/poopsplat/pen/VLdNZq */
.hiscores::before {
    top: 0;
    left: 0;
    z-index: 1;
    width: 100%;
    content: '';
    height: 10px;
    position: absolute;
    background: linear-gradient(180deg, rgba(0,0,0,1), rgba(0,0,0,0));
  }
  .hiscores::after {
    left: 0;
    bottom: 0;
    z-index: 1;
    width: 100%;
    content: '';
    height: 8px;
    position: absolute;
    background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,1));
  }
.hiscores ul{
  list-style: none;
  display: inline-block;
  padding:0;
  margin:0;
  font-size: 2vh;
}
.hiscore-players{
  direction:rtl;
  /* text-align: end; */
  animation: vertical-scroll 12s ease infinite;
  width:10vh;
  text-overflow: hidden;
}
.hiscore-scores{
  text-align: left;
  animation: vertical-scroll 12s ease infinite;
}
.hiscore-scores li{
  margin-left: 0.5vh;
}

main {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  width: 100vw;
  height:95vh;
  border-left: solid transparent 10px;
  border-right: solid transparent 10px;
}

section{
  flex-grow: 1;
  display: flex;
  justify-content: center;
  border: outset rgba(150, 150, 150, 0.75) 10px;
  -webkit-box-shadow: inset 0px 10px 27px -8px #050505, 4px 4px 11px 4px rgba(150, 150, 150, 0.6); 
box-shadow: inset 0px 10px 20px -8px #050505, 4px 4px 5px 4px rgba(150, 150, 150, 0.4);
  margin: 1vh;
  margin-top:0;
  height:max-content;
  min-width: 450px;
}
section.bomb-cursor{
  cursor: url("../assets/bomb-cursor.gif"), auto;
}
section button{
  background-color: #cebabae8;
  padding: 1em;
  width:10em;
  margin-top: 0.5em;
}

small{
  font-size:60%;
}

.rebinding-input{
  border: outset red 2px;
  animation: pulse 2s linear infinite;
}

.info{
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  margin: 0 1vw 0 0.5vw;
}

.score-container{
  font-weight: bolder;
  text-transform: uppercase;
  min-width: 10em;
  display: inline;
}
.score-container>p{
  display: inline-block;
}
.score-container>span{
  display: inline-block;
  text-align: right;
  min-width: 4em;
}

.controls{
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  border: outset rgb(50,50,50) 2px;
  padding:0;
}
.controls *{
  margin: 0.1em 0;
}
.controls span {
  display: inline-block;
  min-width: 2em;
  width: fit-content;
  text-align: center;
}
.control-key>p{
  display: inline-block;
  width: 7em;
}

.bomb{
  align-self: center;
  width: 75px;
  cursor:cell;
}

.play-decorator{
  flex-grow: 1;
  position: relative;
  border: double gold 0.4vh;
  max-width: calc(((90vh)*var(--playmatrix-width-count)/var(--playmatrix-height-count)));
}
tetris-overlay{
  position: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0,0,0,0.5);

  /* Initialise as hidden */
  display: none;
}
tetris-overlay.enable-overlay{
  display: flex;
}
.pause-overlay{
  z-index: 2;
  width: calc(var(--playmatrix-cell-edge-length)*var(--playmatrix-width-count));
  height: calc(var(--playmatrix-cell-edge-length)*var(--playmatrix-height-count));
}
.pause-overlay>p{
  font-family: Audiowide, sans-serif;
  font-size: calc(var(--playmatrix-cell-edge-length)*var(--playmatrix-width-count)/3);
    transform: rotate(-45deg);
}
.play-matrix{
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(var(--playmatrix-width-count), 1fr);
  grid-template-rows: repeat(var(--playmatrix-height-count), 1fr);
}
.play-matrix .debug {
  background-color: rgb(50,50,50);
}
.play-matrix div{
  /* attempt to define all play area sizes based on player1 cell size to retain consistency */
  /* width: var(--playmatrix-cell-edge-length); */
  height: var(--playmatrix-cell-edge-length);
  border: inset rgba(10,10,10, 0.5) 0.6vw;
}
/* .player1 .play-matrix div{ */
  /* attempt to define all play area sizes based on player1 cell size to retain consistency */
  /* width: auto; */
/* } */
.play-matrix div.filled{
  border: outset 0.6vw;
}
.play-matrix .spawn-area{
  background-color: hotpink;
  display: none;
}
.play-matrix div.debug{
  color: grey;
  font-size: 6px;
  display: inherit;
}
.explode::before {
  z-index: 1;
  content: '';
  position: absolute;
  
  width: var(--playmatrix-cell-edge-length);
  height: var(--playmatrix-cell-edge-length); 

  background-image: url(../assets/explosion.gif);
  background-repeat: no-repeat;
  background-size: contain;
}

.create-shape-overlay{
  z-index: 3;
  width:100vw;
  height: 100vh;
}
.create-shape-overlay>div{
  min-width: 200px;
  min-height: 200px;
  opacity: 100%;
  background-color: gray;
}
.shape-creator-matrix-container{
  display: grid;
  grid-template-columns: repeat(var(--shape-creator-matrix-length), 1fr);
  grid-template-rows: repeat(var(--shape-creator-matrix-length), 1fr);
  border:outset 10px steelblue;
}
.shape-creator-matrix-container>div{
  border: outset rgb(175,175,175) 10px;
  width: 80px;
  height: 80px;
  background-color: rgb(200,200,200);
}
.shape-creator-matrix-container .filled{
  background-color: var(--shape-creator-cell-colour);
  border-color: var(--shape-creator-cell-colour);
}
.create-shape-overlay .color-creator-buttons{
  display: flex;
  justify-content: space-around;
  width: 100%;
  margin:10px 0
}
.create-shape-overlay .color-creator-buttons * {
  min-height: 60px;
}

.rainbow-text {
  background-image: repeating-linear-gradient(45deg, violet, indigo, blue, green, yellow, orange, red, violet);
  background-size: 800% 500%;
  -webkit-background-clip: text;
  background-clip:text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: rainbow 15s linear infinite;
}
.allcaps {
  text-transform: uppercase;
}
.inactive-element {
  filter:brightness(30%);
}

@keyframes rainbow { 
    0%{background-position:0% 75%}
    50%{background-position:100% 25%}
    100%{background-position:0% 75%}
}
@keyframes pulse {
	0% {
		transform: scale(1.0);
		box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.7);
    background-position:0% 75%
	}

	50% {
		transform: scale(1.2);
		box-shadow: 0 0 0 10px rgba(0, 0, 0, 0);
    background-position:100% 25%;
	}

	100% {
		transform: scale(1.0);
    background-position:0% 75%;
	}
}
@keyframes vertical-scroll {
  0%   { transform:translateY(    0); }
  10%  { transform:translateY(    0); }
  18%  { transform:translateY( -3vh); }
  26%  { transform:translateY( -6vh); }
  34%  { transform:translateY( -9vh); }
  42%  { transform:translateY(-12vh); }
  50%  { transform:translateY(-15vh); }
  58%  { transform:translateY(-18vh); }
  66%  { transform:translateY(-21vh); }
  71%  { transform:translateY(-24vh); }
  82%  { transform:translateY(-27vh); }
  90%  { transform:translateY(-30vh); }
  98%  { transform:translateY(-30vh); }
  100% { transform:translateY(    0); }
}

@keyframes horizontal-scroll{
  0%   {transform:translateX(  0);}
  100% {transform:translateX(-100%);}
}

@media screen and (max-width: 800px) {
  main {
    height: fit-content;
  }
  header h1{
    margin: 0 0.5vw 0 0.5vw;
  }

  header button{
    font-size: 50%;
    margin: 0 0.5vw 0 0.5vw;
    width: 10vw;
  }
  header button span {
    display: none;
  }
  .pause-button{
    order:1;
  }
  .new-player-button{
    display: none;
    filter: opacity(0.4);
  }
  .hiscores{
    overflow: hidden;
    width: 10vw;
    height: 100%;
    font-weight: bolder;
  }
  .hiscores ul {
    display: block;
    overflow: hidden;
    font-size: 50%;
    height: 50%;
    width: 170vw;
    margin: 0;

    display: flex;
    flex-wrap: nowrap;
  }
  .hiscores li {
    margin:0;
    width: 15vw;
    text-align: center;
    display: inline-block;
  }
  .hiscore-players{
    align-items: flex-end;
    height: fit-content;
    direction:ltr;
    animation: horizontal-scroll 60s linear infinite;
  }
  .hiscore-scores{
    animation: horizontal-scroll 60s linear infinite;
  }
  main{
    align-content: center;
    border: 0;
  }
  section{
    flex-grow: 0;
    flex-direction: column-reverse;
    align-items: center;
    width: min-content;
    min-width: min-content;
    /* max-width: 95vw; */
    margin:0;
    box-shadow: none;
  }
  .play-decorator{
    flex-grow: 1;
    height:fit-content;
    width:95vw;
  }
  .info{
    width: 100%;
    align-items: center;
    margin: 0;
  }
  .info *{
    margin: 0;
  }
  .control-key>p{
    width: fit-content;
  }
  ul>p {
    display: none;
  }
  .controls{
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
  }
  .controls div{
    border: solid gray 2px;
    margin: 3px;
    padding: 0.4em;
  }
}