:root {
  --headerBC: hsla(0, 0%, 100%, 0.25);
  --boxBC: hsla(0, 0%, 100%, 0.15);
  --gameBC: rgba(255, 255, 255, 0.1);
  --shake: 5px;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  color: hsla(0, 0%, 93%, 0.5);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  -webkit-user-drag: none;
}

body {
  height: 100vh;
  width: 100vw;
  background: linear-gradient(rgb(12 6 35), #000);
  display: flex;
  align-items: center;
  padding: 10px;
  flex-direction: column;
  user-select: none;
}

#loading {
  display: grid;
  place-content: center;
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999;
  background: linear-gradient(rgb(12 6 35), #000);
}

#loading img {
  height: 50px;
  width: 50px;
  filter: invert(1);
  animation: spin 0.75s infinite linear;
}

header {
  min-height: 200px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

header img {
  height: 50px;
}

nav {
  height: 50px;
  width: 500px;
  max-width: 100%;
  margin-bottom: 10px;
  display: flex;
  padding: 0.1rem;
  justify-content: space-between;
}

nav img {
  max-height: 100%;
}

nav .turn {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 25px;
  border-radius: 5px;
  background-color: hsla(0, 0%, 100%, 0.1);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}

.fadeup {
  animation: fadeup 0.5s ease;
}

nav .turn img {
  width: 20px;
  opacity: 0.75;
  margin-right: 10px;
}

button {
  color: #333;
  background-color: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  bottom: 0px;
  max-width: 46px;
}

.jump-anim {
  animation: jump 0.25s ease infinite alternate;
}

button:hover {
  opacity: 0.75;
}

.game {
  padding: 15px;
  background-color: var(--gameBC);
  border-radius: 10px;
  width: 500px;
  max-width: 100%;
  position: relative;

  /* DISABLE BLUE HIGHLIGHT WHEN TOUCHING ON PHONE */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.score {
  display: none;
  margin-top: 10px;
  width: 500px;
  max-width: 100%;
  justify-content: space-between;
  align-items: center;
}

.score .score-img {
  height: 30px;
}

.score div {
  display: flex;
  align-items: center;
  background-color: var(--gameBC);
  border-radius: 10px;
  padding: 0 20px;
  border: 1px solid transparent;
}

.aside-score {
  display: flex;
  align-items: center;
  padding: 10px;
  flex-direction: column;
  width: 50px;
  background-color: var(--gameBC);
  border-radius: 5px;
  position: absolute;
  top: 20%;
  transform: translateY(-50%);
  cursor: default;
  border: 1px solid transparent;
}

.aside-score.left-score small {
  color: rgb(17, 219, 17);
}
.aside-score.right-score small {
  color: tomato;
}

.score-img {
  margin-top: 10px;
  margin-bottom: 8px;
}

.score-num {
  font-family: "Squada One", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-weight: bold;
  font-size: 2rem;
}

.x-score-num {
  color: rgb(17, 219, 17);
}
.o-score-num {
  color: tomato;
}

.score .x-score-num {
  color: rgb(17, 219, 17);
  margin-left: 10px;
}
.score .o-score-num {
  color: tomato;
  margin-right: 10px;
}

.right-score {
  right: -60px;
}
.left-score {
  left: -60px;
}

.container {
  width: 100%;
  aspect-ratio: 1/1;
  border-radius: 5px;
  display: grid;
  grid-template: 1fr 1fr 1fr/ 1fr 1fr 1fr;
  gap: 15px;
  transition: 0.1s;
}

.a {
  border-top-left-radius: 5px;
}
.c {
  border-top-right-radius: 5px;
}
.g {
  border-bottom-left-radius: 5px;
}
.i {
  border-bottom-right-radius: 5px;
}

.box {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--boxBC);
  overflow: hidden;
}

.box:hover {
  filter: opacity(0.9);
  box-shadow: inset 0 0 50px rgba(255, 255, 255, 0.15),
    inset 0 0 1px 3px rgba(255, 255, 255, 0.5);
}

[checked="X"],
[checked="O"] {
  background-size: contain;
  padding: 15%;
}

[checked="X"]:hover,
[checked="O"]:hover {
  filter: opacity(0.9);
  box-shadow: inset 0 0 50px rgba(255, 102, 0, 0.15),
    inset 0 0 1px 3px rgba(255, 102, 0, 0.5);
}

.img {
  height: 100%;
  width: 100%;
  background-size: contain;
}

img {
  height: 100%;
  width: 100%;
  position: relative;
}

[checked="X"] .img,
[checked="O"] .img {
  animation: pop 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
[checked="X"] .img {
  background-image: url("./imgs/X.svg");
}
[checked="O"] .img {
  background-image: url("./imgs/O.svg");
}

.winner {
  background-color: rgb(17, 219, 17);
  box-shadow: 0 0 15px rgba(17, 219, 17, 0.5);
  border: 5px solid rgba(0, 128, 0, 0.5);
  transition: 0.05s;
}

.draw {
  background-color: darkorange;
  box-shadow: 0 0 15px rgba(255, 140, 0, 0.5);
}

.error {
  background-color: tomato;
  box-shadow: 0 0 15px rgba(255, 99, 71, 0.5);
}

.game[disabled] {
  pointer-events: none;
}
.game:not([disabled]) {
  cursor: pointer;
}

.score-anim {
  animation: score-glow 0.75s linear;
}

footer {
  height: 100px;
  display: flex;
  justify-content: center;
  align-items: center;
}
footer p span {
  color: hsla(0, 0%, 100%, 0.25);
}
footer a {
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes score-glow {
  from {
    border: 1px solid white;
    background-color: hsla(0, 0%, 100%, 0.5);
  }
  to {
    border: 2px solid transparent;
    background-color: var(--gameBC);
  }
}

@keyframes shake {
  from {
    right: calc(-1 * var(--shake));
  }
  to {
    right: var(--shake);
  }
}

@keyframes pop {
  from {
    /* opacity: 0.2; */
    transform: scale(0.5);
  }
  to {
    /* opacity: 1; */
    transform: scale(1);
  }
}

@keyframes jump {
  from {
    top: 0px;
  }
  to {
    /* opacity: 1; */
    top: -5px;
  }
}

@keyframes fadeup {
  from {
    border: 1px solid rgba(255, 255, 255, 0.25);
  }
  to {
    border: 1px solid transparent;
  }
}

@media screen and (max-width: 762px) {
  .aside-score {
    display: none;
  }

  .score {
    display: flex;
  }
}

@media screen and (max-width: 400px) {
  .score > p {
    display: none;
  }
}
