@import url('https://fonts.googleapis.com/css2?family=Almendra+SC&display=swap');

:root {
  --tile-width: 32px;
  --bump-amount: 0.25;
}

@media only screen and (max-device-width: 600px) {
  :root {
    --tile-width: 16px;
    font-size: 0.75em;
  }
}

* {
  box-sizing: border-box;
}

html {
  background-color: #FCFBF3;
}

html, body, #app, #loading {
  min-height: 100%;
}

body {
  max-width: 100%;
  width: 800px;
  margin: auto;
  font-family: "Courier New", "Courier", "Courier 10 Pitch", monospace;
  font-weight: bold;
  font-size: 2em;
  color: #31373D;
  touch-action: pan-y;
}

footer {
  text-align: center;
}

@media only screen and (max-device-width: 600px) {
  div.row {
    transform: translateY(-3em);
  }
}

p {
  font-weight: bold;
}

h1, h2, h3 {
  font-family: 'Almendra SC', serif;
}

button, .button {
  border: 2px solid #4D9029;
  border-bottom: 5px solid #4D9029;
  background-color: #78B159;
  border-radius: 6px;
  font-family: "Courier New", "Courier", "Courier 10 Pitch", monospace;
  font-size: 1em;
  font-weight: bold;
  color: #555;
  padding: 0.25em 0.5em;
}

button:active, .button:active {
  border-bottom: 2px solid #4D9029;
  margin-bottom: 3px;
  transform: translateY(4px);
}

button.key {
  border: 2px solid #AAB8C2;
  border-bottom: 5px solid #AAB8C2;
  background-color: #D4E1EA;
}

button.key:active {
  border-bottom: 2px solid #AAB8C2;
}

button.key svg {
  width: 1em;
  height: 1em;
}

button.key svg path {
  fill: #555;
}

inline-icon {
  width: 2em;
  height: 2em;
  color: #555;
  fill: #555;
}

/***** specific styles *****/

#app {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/***** text page specific styles *****/

body.page {
  height: 100vh;
  padding: 0.5em;
}

button#help {
  position: absolute;
  top: 8px;
  left: 8px;
}

a {
  color: grey;
  font-size: 0.75em;
}

.page a.button {
    text-decoration: none;
    color: white;
}

.page .cta {
  text-align: center;
}

.page.admin li {
  font-size: 0.75em;
}

/***** game styles *****/

body.game {
  width: 100%;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

body.game #app {
  align-items: center;
}

#game {
  display: flex;
  justify-content: center;
}

#game h1 {
  position: absolute;
  top: 0px;
  text-align: center;
  margin: auto;
  width: 100%;
  left: 0px;
}

h1.splash {
  position: absolute;
  z-index: 3;
  text-shadow: 0px 0px 10px white;
  font-size: 6em;
  top: 100px !important;
}

div.row {
  height: var(--tile-width);
}

span.grid {
  display: inline-block;
  width: var(--tile-width);
  height: var(--tile-width);
}

span.grid > * {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
}

img.tile {
  width: var(--tile-width);
  /* uncomment for pixelated sprites
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  */
}

span.stat {
  font-size: 0.5em;
  top: -1em;
  position: absolute;
  color: #333;
  text-shadow: 0px 0px 3px white;
  opacity: 0.5;
}

span.xp {
  display: inline-block;
  width: var(--tile-width);
  height: var(--tile-width);
  vertical-align: top;
  font-size: 0.75em;
  text-align: center;
  position: relative;
  top: 0.15em;
}

#health-bars {
  top: 8px;
  margin: auto;
  position: absolute;
}

#event-modal {
  padding: 1em;
  border: 2px solid #AAB8C2;
  background-color: #D4E1EA;
  border-radius: 6px;
  position: absolute;
  top: 100px;
  box-shadow: 0px 0px 20px #888;
  animation: modal-off 1.5s forwards;
}

#event-modal img.tile {
  width: calc(var(--tile-width) * 3);
}

@keyframes modal-off {
  0% {
    display: block;
    opacity: 1;
  }
  75% {
    display: block;
    opacity: 1;
  }
  100% {
    display: none;
    opacity: 0;
  }
}


#score {
  position: absolute;
  bottom: 128px;
  left: 0px;
  width: 100%;
  text-align: center;
  font-weight: bold;
}

#inventory ul {
  position: absolute;
  bottom: 8px;
  left: 0px;
  list-style-type: none;
  display: flex;
  width: 100%;
  justify-content: center;
  padding: 0px;
  margin: 0px;
}

#inventory li {
  display: inline-block;
}

#inventory li + li {
  margin-left: 0.25em;
}

#arrow-buttons {
  position: absolute;
  bottom: 1.5em;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  right: 0.5em;
}

#arrow-buttons > div {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#arrow-buttons button span {
  vertical-align: sub;
}

#arrow-buttons button svg {
  vertical-align: text-top;
}

.modal {
  position: absolute;
  top: 0px;
  left: 0px;
  width: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1em;
  background-color: #FCFBF3;
  z-index: 2;
}

.message {
  position: absolute;
  bottom: 8px;
  left: 0px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tombstone {
  background-color: white;
  border-radius: 6px;
  border: 1px solid #CCD6DD;
  padding: 1em;
  margin: 1em;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  max-width: 600px;
  width: 95%;
  text-align: center;
  font-size: 0.75em;
}

.tombstone #stats {
}

.tombstone #stats p {
  margin: 0px;
}

.tombstone hr {
  width: 100%;
  border: none;
  height: 1px;
  background-color: #CCD6DD;
}

.tombstone .countdown {
  margin: 0.5em;
  margin-bottom: 0px;
}

.tombstone .shared {
  margin: 0px;
  display: flex;
}

.tombstone .shared inline-icon {
  margin: 0.25em;
}

.tombstone + .tombstone {
  margin-top: 1em;
}

.ad {
  display: flex;
  flex-direction: column;
  text-align: center;
  text-decoration: none;
  color: #111;
  font-size: 1em;
}

.ad img {
  max-width: 100%;
  margin: 1em 0px;
}

.ad p {
  margin: 0.5em;
}

.feedback {
  font-size: 0.75em;
}

.feedback a {
  text-decoration: none;
}

.build {
  font-size: 0.5em;
  color: grey;
}

.donations > * {
  display: block;
  margin: 0.25em;
}

.donation-patreon {
  background-color: #ff424d;
  border-radius: 100px;
  color: white;
  padding: 8px 20px;
  text-decoration: none;
  font-size: 1rem;
}

.donation-patreon svg {
  height: 1rem;
  width: 1rem;
  vertical-align: sub;
  stroke-width: 1.2px;
  fill: white;
  margin-right: 8px;
  padding-bottom: 1px;
}

/***** juice *****/

.pop {
  animation: pop .25s;
}

@keyframes pop {
  from {
    transform: scale(0);
    animation-timing-function: cubic-bezier(.59,2.5,.88,.32);
  }
  to {
    transform: scale(1);
  }
}

.grow-and-fade {
  animation: grow-and-fade 1s forwards;
}

@keyframes grow-and-fade {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(3);
    opacity: 0;
  }
}

.bump-up {
  animation: bump-up .25s;
}

@keyframes bump-up {
  from {
    transform: translateY(calc(var(--tile-width) * var(--bump-amount) * -1));
  }
  to {
    transform: translateY(0px);
  }
}

.bump-left {
  animation: bump-left .25s;
}

@keyframes bump-left {
  from {
    transform: translateX(calc(var(--tile-width) * var(--bump-amount) * -1));
  }
  to {
    transform: translateX(0px);
  }
}

.bump-down {
  animation: bump-down .25s;
}

@keyframes bump-down {
  from {
    transform: translateY(calc(var(--tile-width) * var(--bump-amount)));
  }
  to {
    transform: translateY(0px);
  }
}

.bump-right {
  animation: bump-right .25s;
}

@keyframes bump-right {
  from {
    transform: translateX(calc(var(--tile-width) * var(--bump-amount)));
  }
  to {
    transform: translateX(0px);
  }
}

/***** loader *****/

#loading {
  display: flex;
  justify-content: center;
  align-items: center;
}

#loading div {
  animation: spin 0.33s linear infinite;
  width: 48px;
  height: 48px;
  border-radius: 24px;
  border: 3px solid transparent;
  border-left: 3px solid silver;
  border-right: 3px solid silver;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
