@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

* {
  box-sizing: border-box;
  font-family: 'Roboto', sans-serif;
}

:root {
  --header-height: 45px;
  --content-padding-top: calc(var(--header-height) + 20px);
  --content-padding-bottom: 10px;
  --message-container-height: 80px;
}

.hidden {
  display: none !important;
}

.invisible {
  visibility: hidden !important;
}

.disabled {
  opacity: 0.3 !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  user-select: none !important;
  transform: none !important;
  pointer-events: none !important;
}

.no-scroll {
  overflow-y: hidden !important;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin: 0 auto;
  background-image: url("../images/big-sur-bg.jpeg");
  background-size: cover;
  padding-top: var(--content-padding-top);
  padding-bottom: var(--content-padding-bottom);
  min-height: 100vh;
}

.blurred-background {
  -webkit-backdrop-filter: blur(2rem);
  backdrop-filter: blur(2rem);
}

.tooltipped {
  /* Not making this !important so it only takes effect if position is not
  set. */
  position: relative;
}

.tooltipped:hover::after {
  content: var(--tooltip-text);
  font-size: 0.8rem;
  color: #333333;
  background: rgba(255, 255, 255, 0.9);
  position: absolute;
  width: 50%;
  min-width: 15ch;
  max-width: 25ch;
  top: -5px;
  left: calc(100% + 5px);
  padding: 5px 5px;
  z-index: 100000;
  box-shadow: 0px 0px 5px 3px rgb(50 50 50 / 25%);
  border-radius: 5px;
  text-align: center;
}

header {
  display: flex;
  flex-direction: row;
  align-items: center;
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  height: var(--header-height);
  width: 100%;
  padding: 3px 15px;
  /* background: rgba(0, 0, 50, 0.2); */
  background: rgba(0, 0, 50, 0.5);
  box-shadow: 0px 0px 4px 0px black;
}

header #coin-balance-display {
  display: flex;
  align-items: center;
  margin-right: auto;
}

.material-symbols-rounded.filled,
.material-symbols-outlined.filled {
  font-variation-settings: 'FILL'1 !important;
}

/* for icons */
header .material-symbols-rounded,
header .material-symbols-outlined {
  font-variation-settings:
    'FILL'1,
    'wght'700,
    'GRAD'200,
    'opsz'48
}

#coin-balance-display .coin,
#coin-balance-display #coin-balance {
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-right: 10px;
}

.coin {
  color: gold;
}

#coin-balance {
  color: white;
}

#controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  height: 24px;
  border-right: 1px solid rgba(255, 255, 255, 0.5);
  padding-right: 10px;
  margin-left: auto;
  margin-right: 40px;
}

#controls:empty {
  border: none;
}

#controls span {
  font-size: 24px !important;
  line-height: 36px !important;
  color: white;
  cursor: pointer;
  /* TODO: Make this responsive. */
  margin-right: 20px;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

#controls span:last-child {
  margin-right: 5px;
}

#gem-icon {
  color: #FF577F !important;
}

#gem-icon.gems-available {
  position: relative;
  margin-right: 15px !important;
  --num-available-gems: "";
}

#gem-icon.gems-available::after {
  content: var(--num-available-gems);
  position: absolute;
  left: 95%;
  top: -9px;
  font-family: 'Roboto';
  font-size: 0.6em;
  color: white;
  font-weight: bold;
  z-index: 10;
}

#help-toggle {
  margin-right: 20px;
}

nav {
  display: flex;
  justify-content: flex-end;
  width: -webkit-fit-content;
  width: -moz-fit-content;
  width: fit-content;
  max-width: 1500px;
}

nav span {
  font-size: 30px !important;
  line-height: 36px !important;
  color: white;
}

nav a:hover,
nav a:focus {
  text-shadow: 0px 0px 12px white;
}

.align-children-page-center {
  width: 100vw;
  height: calc(100vh - var(--content-padding-top) - var(--content-padding-bottom));
  display: flex;
  justify-content: center;
  /* justify-content: flex-start; */
  align-items: center;
}

/* Login */
#login {
  /* Should be flex, but hide. Show as appropriate using JS logic. */
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  width: 100vw;
}

#login-user {
  display: flex;
  /* display: none; */
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

#profile-img {
  width: 200px;
  aspect-ratio: 1;
  -o-object-fit: cover;
  object-fit: cover;
  border-radius: 50%;
}

/* TODO: Add box shadow. */
#username {
  margin-top: 40px;
  color: white;
  text-shadow: 2px 2px 9px #555;
  font-size: 1.8rem;
  letter-spacing: 1px;
}

#username-form {
  position: relative;
  /* For the button - position: absolute */
}

/* TODO: Add -> arrow as in macOS. */
#username-input,
#username-input:focus,
#username-input:focus-within {
  /* display: none; */
  border: none;
  outline: none;
  border-radius: 99px;
  height: 35px;
  width: 200px;
  padding-left: 15px;
  padding-right: 15px;
  font-size: 19px;
  font-family: Verdana;
  letter-spacing: 0.125em;
  background-color: #888;
  color: #DDD;
}

#username-input::-moz-placeholder {
  color: #DDD;
  font-size: 18px;
  font-family: Roboto;
  letter-spacing: 0px;
}

#username-input::placeholder {
  color: #DDD;
  font-size: 18px;
  font-family: Roboto;
  letter-spacing: 0px;
}

.username-input-invalid {
  -webkit-animation: macos-invalid-password-shake .5s linear;
  animation: macos-invalid-password-shake .5s linear;
}

#login-button {
  display: none;
  position: absolute;
  font-size: 35px;
  color: #CCC;
  right: 0px;
  top: 0px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

/*
Only show the login button if input is not empty. Trick borrowed from:
https://zellwk.com/blog/check-empty-input-css/
*/
#username-input:not(:-moz-placeholder-shown)~button {
  display: block !important;
}

#username-input:not(:placeholder-shown)~button {
  display: block !important;
}

/* https://stackoverflow.com/questions/15726000/css-animation-similar-to-mac-os-x-10-8-invalid-password-shake */
@-webkit-keyframes macos-invalid-password-shake {
  8%, 41% {
    transform: translateX(-10px);
  }

  25%, 58% {
    transform: translateX(10px);
  }

  75% {
    transform: translateX(-5px);
  }

  92% {
    transform: translateX(5px);
  }

  0%, 100% {
    transform: translateX(0);
  }
}

@keyframes macos-invalid-password-shake {
  8%, 41% {
    transform: translateX(-10px);
  }

  25%, 58% {
    transform: translateX(10px);
  }

  75% {
    transform: translateX(-5px);
  }

  92% {
    transform: translateX(5px);
  }

  0%, 100% {
    transform: translateX(0);
  }
}

/* Dashboard */
#game-list {
  /* This should be flex, but overriding with none (until logged in) */
  display: flex;
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  /* margin-top: min(100px, 20%); */
  align-items: flex-start;
  /* padding-top: min(50px, 25%); */
  height: -webkit-fit-content;
  height: -moz-fit-content;
  height: fit-content;
}

.game-card {
  --game-card-width: 90px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: var(--game-card-width);
  aspect-ratio: 1.5;
  margin: 20px;
  margin-bottom: 30px;
  /* border: 3px solid rgba(255, 255, 255, 0.8); */
  /* background-color: rgba(255, 50, 50, 0.2); */
  color: white;
  border-radius: 5px;
  /* box-shadow: 0 2px 15px 0px #555; */
  cursor: pointer;
}

.game-card.game-card-disabled {
  cursor: initial;
}

.game-card>img {
  /* Set these explicitly for iOS Safari */
  width: var(--game-card-width);
  height: var(--game-card-width);
  -o-object-fit: cover;
  object-fit: cover;
  border-radius: 20px;
  box-shadow: 0px 1px 5px 1px #555;
}

.game-card>h3 {
  text-align: center;
  font-size: 0.8rem;
  font-weight: bold;
  color: inherit;
  text-align: center;
  margin-top: 10px;
  margin-bottom: 10px;
  /* border: 3px solid rgba(255, 255, 255, 0.8); */
  /* border-radius: 99vh;
  background: rgba(0, 0, 0, 0.2); */
  width: 100%;
  padding: 5px;
}

.game-card>.coming-soon-text {
  position: absolute;
  bottom: 0px;
  display: flex;
  /* width: 100%; */
  padding: 5px;
  background: rgba(255, 255, 255, 0.5);
  font-size: 1rem;
  text-align: center;
  color: black;
  padding: 3px;
  top: -5px;
  left: -5px;
  right: -5px;
  justify-content: center;
  align-items: center;
  -webkit-backdrop-filter: blur(1px);
  backdrop-filter: blur(1px);
  /* This envelopes the game-card image, so perfect radius =
       game-card img border radius + this box's padding */
  border-radius: 23px;
}

.game-card>.beta-text {
  width: 50px;
  padding: 1px 10px;
  color: white;
  position: absolute;
  top: -15px;
  left: calc(100% - 25px);
  text-align: center;
  right: 0;
  font-size: 70%;
  z-index: 1;
  text-transform: uppercase;
}

/* Game */
#game-area {
  display: flex;
  flex-direction: column;
  --grid-square-width: max(8vw, 90px);
  --o-color: #e9cf0e;
  --x-color: #72f2e5;
}

/* Notifications */
#message-area {
  margin: 15px auto;
  padding: 2px 8px;
}

#message-area, #message-container {
  width: -webkit-fit-content;
  width: -moz-fit-content;
  width: fit-content;
  min-width: 275px;
  max-width: 300px;
  height: var(--message-container-height);
}

#message-container {
  position: fixed;
  top: calc(-1 * var(--message-container-height));
  z-index: 100000;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.9rem;
  font-weight: bold;
  text-align: center;
  color: #333;
  /* TODO: add some padding and make it work on all devices. */
  /* padding: 5px 10px; */
  background: rgba(255, 255, 255, 0.8);
  /* visibility: hidden; */
  border-radius: 5px;
  box-shadow: 0 0 10px 2px rgba(0, 0, 0, 0.2);
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  transition: top 500ms ease-in-out;
}

#message-container.active-notification {
  visibility: visible;
  top: 5px;
}

#message-container a {
  font-size: 110%;
  color: blue;
}

/* The X and O have different intrinsic sizes that we need to compensate for
below. This ensures they're vertically aligned.
*/
.character {
  display: flex;
  align-items: center;
  justify-content: center;
}

#whos-turn {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  width: calc(var(--grid-square-width) * 3 + 20px);
  padding: 8px;
  font-size: 2rem !important;
  font-weight: bold;
  color: white;
  margin: 0 auto;
  text-align: center;
  text-transform: uppercase;
  margin-bottom: 10px;
}

#whos-turn>.character {
  visibility: hidden;
  width: 4rem;
  font-weight: bold;
  transition: visibility 50ms ease-in;
}

#whos-turn>.shown {
  visibility: visible;
}

#whos-turn>span.character-o {
  font-size: calc(4rem * .75);
  color: var(--o-color);
}

#whos-turn>span.character-x {
  font-size: 4rem;
  color: var(--x-color);
}

#whos-turn #turn-label {
  color: white;
  font-size: 1.25rem;
  display: flex;
  justify-content: center;
  align-items: center;
  text-shadow: 0 0 5px #999;
}

#grid, #scores {
  width: calc(3 * var(--grid-square-width));
}

#scores {
  display: flex;
  justify-content: space-between;
  min-width: 300px;
  margin-bottom: 10px;
  margin-top: 20px;
}

.score-card {
  position: relative;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  color: white;
  background-color: #555;
  width: var(--grid-square-width);
  height: 30px;
  /* border-radius: 99vw; */
  padding: 5px 15px;
  background: rgba(100, 0, 0, 0.5);
  box-shadow: 0 0 10px 2px rgba(0, 0, 0, 0.2);
}

.score-card>span {
  display: block;
  position: absolute;
  width: 50%;
  height: 100%;
}

.score-card>span.character {
  font-weight: bold;
  font-size: 2rem;
  text-align: center;
  border-right: 2px solid #AAA;
  margin-right: 5px;
  left: 0;
  /* border-top-left-radius: 99vh;
  border-bottom-left-radius: 99vh; */
  line-height: 30px;
  color: #000;
}

.score-card>span.score {
  position: absolute;
  width: 50%;
  height: 100%;
  font-weight: bold;
  font-size: 1.25rem;
  /* width: 3ch; */
  text-align: center;
  right: 0;
  line-height: 30px;
}

/* The O icon from Material is a little larger than the X. */
.score-card>span.character-o {
  font-size: calc(2rem * .75);
  color: var(--o-color);
}

.score-card>span.character-x {
  color: var(--x-color);
}

#grid {
  /* Add 20px for border. */
  width: calc(3 * var(--grid-square-width) + 20px);
  display: flex;
  flex-wrap: wrap;
  border: 10px solid rgba(100, 100, 100, 0.4);
  border-radius: 10px;
}

.grid-square {
  border: 1px solid #AAA;
  /* border-radius: 10px; */
  /* Set these explicitly for iOS Safari */
  width: var(--grid-square-width);
  height: var(--grid-square-width);
  background: rgba(0, 0, 0, 0.2);
  color: white;
}

.grid-square.top {
  border-top: 0px;
}

.grid-square.left {
  border-left: 0px;
}

.grid-square.bottom {
  border-bottom: 0px;
}

.grid-square.right {
  border-right: 0px;
}

.grid-square>span {
  font-size: calc(var(--grid-square-width) * 0.9);
  text-align: center;
  width: 100%;
  height: 100%;
  line-height: var(--grid-square-width);
}

.grid-square.character-o>span {
  color: var(--o-color);
}

.grid-square.character-x>span {
  color: var(--x-color);
}

/* Google Material font class for the X and O */
.grid-square>span.material-symbols-outlined {
  font-variation-settings:
    'FILL'0,
    'wght'300,
    'GRAD'200,
    'opsz'48
}

/* The Material icon used for O is a litte larger than the one for X. */
.grid-square[data-value='O']>span {
  font-size: calc(var(--grid-square-width) * 0.75);
}

/* Used to Highlight the winning combination. */
.grid-square.inverted {
  background: rgba(255, 255, 255, 0.5);
  border: none;
  -webkit-animation: winner-dance 2s ease-in;
  animation: winner-dance 2s ease-in;
  box-shadow: 5px 5px 14px 4px rgb(85 85 85 / 50%);
}

.grid-square.inverted.character-o {
  background-color: var(--o-color);
}

.grid-square.inverted.character-x {
  background-color: var(--x-color);
}

.grid-square.inverted>span.character {
  color: #555 !important;
}

@-webkit-keyframes winner-dance {
  0%, 7% {
    transform: rotateZ(0);
  }

  15% {
    transform: rotateZ(-15deg);
  }

  20% {
    transform: rotateZ(10deg);
  }

  25% {
    transform: rotateZ(-10deg);
  }

  30% {
    transform: rotateZ(6deg);
  }

  35% {
    transform: rotateZ(-4deg);
  }

  40%, 100% {
    transform: rotateZ(0);
  }
}

@keyframes winner-dance {
  0%, 7% {
    transform: rotateZ(0);
  }

  15% {
    transform: rotateZ(-15deg);
  }

  20% {
    transform: rotateZ(10deg);
  }

  25% {
    transform: rotateZ(-10deg);
  }

  30% {
    transform: rotateZ(6deg);
  }

  35% {
    transform: rotateZ(-4deg);
  }

  40%, 100% {
    transform: rotateZ(0);
  }
}

.grid-square.disabled {
  background: rgba(170, 170, 170, 0.75);
  color: rgba(255, 255, 255, 0.75);
  -webkit-animation: macos-invalid-password-shake .5s ease-in;
  animation: macos-invalid-password-shake .5s ease-in;
}

#restart-game-button {
  display: none;
  width: 210px;
  height: 40px;
  margin-top: 20px;
  margin-left: auto;
  margin-right: auto;
  border-radius: 99vh;
  border: 0px;
  background-color: white;
  color: #555;
  font-family: Verdana;
  font-size: 1rem;
  font-weight: bold;
}

#restart-game-button:hover,
#restart-game-button:focus {
  box-shadow: 1px 2px 6px 1px #999;
  cursor: pointer;
}

/* Hangman */
.score-card#hangman-score-card {
  margin-top: 0;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 20px;
  justify-content: flex-start;
  padding: 5px;
  width: 100%;
  height: 50px;
  background: none;
  border-bottom: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 0;
  box-shadow: none;
  /* This is in the generic scorecard class. Remove. */
}

.score-card .coin {
  position: relative;
  width: 2rem;
  margin-right: 10px;
  font-size: calc(2rem * 1.25);
  font-weight: bold;
  text-align: center;
  line-height: 25px;
  color: gold;
  text-shadow: 0 0px 20px rgb(255 255 255 / 40%);
}

.coin.material-symbols-outlined {
  font-variation-settings:
    'FILL'1,
    'wght'700,
    'GRAD'200,
    'opsz'48
}

/* For the animation */
.visible-coin {
  -webkit-animation: reveal-coin 0.2s ease-in;
  animation: reveal-coin 0.4s ease-in;
}

.coin-to-bank {
  -webkit-animation: flying-coin 0.9s ease-in-out;
  -webkit-animation-fill-mode: forwards;
  animation-fill-mode: forwards;
}

@-webkit-keyframes reveal-coin {
  0% {
    visibility: hidden;
    opacity: 0;
  }

  70% {
    opacity: 0.5;
    transform: translateY(-5px);
  }

  90% {
    transform: translateY(10px);
    visibility: visible;
    opacity: 100;
  }

  100% {
    transform: translateY(-10px);
  }
}

@keyframes reveal-coin {
  0% {
    visibility: hidden;
    opacity: 0;
  }

  70% {
    opacity: 0.5;
    transform: translateY(-5px);
  }

  90% {
    transform: translateY(25px);
    visibility: visible;
    opacity: 100;
  }

  100% {
    transform: translateY(-25px);
  }
}

@-webkit-keyframes flying-coin {
  5% {
    transform: translate(-10px, -10px);
    opacity: 1
  }

  50% {
    opacity: 0.4
  }

  100% {
    transform: translate(-1200px, -1200px);
    opacity: 0;
    display: none;
  }
}

@keyframes flying-coin {
  5% {
    transform: translate(-10px, -10px);
    opacity: 1
  }

  50% {
    opacity: 0.4
  }

  100% {
    transform: translate(-1200px, -1200px);
    opacity: 0;
    display: none;
  }
}

/* TODO: Could make this more generic for reusability. */
.hidden-coin {
  visibility: hidden !important;
  opacity: 0 !important;
  transition: visibility 1s, opacity 1s ease-in;
}

#grid.hangman {
  flex-wrap: nowrap;
  width: -webkit-fit-content;
  width: -moz-fit-content;
  width: fit-content;
  border: none;
  margin-bottom: 20px;
}

#grid.hangman.incorrect-word>.grid-square {
  background: rgba(255, 255, 255, 0.5);
  -webkit-animation: macos-invalid-password-shake .5s linear;
  animation: macos-invalid-password-shake .5s linear;
}

#grid.hangman.correct-word {
  -webkit-animation: winner-dance 1s linear;
  animation: winner-dance 1s linear;
  transition: color 0.3s, box-shadow 0.3s ease-in-out;
}

#grid.hangman>.grid-square {
  width: 50px;
  height: 50px;
  margin: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#grid.hangman>.grid-square>span {
  font-size: 32px;
  text-align: center;
  display: inline-block;
  line-height: 50px;
}

#grid.hangman.correct-word> {}

#grid.hangman.correct-word>.grid-square {
  border: none;
  background: none;
}

#grid.hangman.correct-word>.grid-square>span {
  text-shadow: 0 0 8px gold;
  color: white;
  font-weight: bold;
}

#grid.hangman>.grid-square>span.red {
  color: #d20303 !important;
}

#hint-button {
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 30px;
  padding: 0;
  margin-bottom: 10px;
  text-align: center;
  color: #555;
  border-radius: 5px;
  border: none;
  background-color: rgb(255, 255, 255);
}

#hint-button>.coin {
  color: gold;
  display: inline-block;
}

#hint-button>.coin:nth-of-type(1) {
  color: gold;
  margin-left: 15px;
}

#keyboard {
  width: 90%;
  max-width: 720px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.letter-button {
  font-size: 1.5rem;
  width: 3.5ch;
  aspect-ratio: 1;
  padding: 0;
  text-align: center;
  margin: 4px;
  /* font-weight: bold; */
  background-color: rgb(255, 255, 255);
  color: #555;
  border-radius: 5px;
  border: none;
}

.letter-button.incorrect-letter {
  -webkit-animation: macos-invalid-password-shake .5s ease-in;
  animation: macos-invalid-password-shake .5s ease-in;
  opacity: 0.5;
}

.letter-button.correct-letter {
  -webkit-animation: winner-dance 2s ease-in;
  animation: winner-dance 2s ease-in;
  opacity: 0.5;
}

#instructions-overlay {
  position: fixed;
  top: 0;
  left: 0;
  /* Explicitly set this so it's just smaller than header. */
  z-index: 99;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  -webkit-backdrop-filter: grayscale(1);
  backdrop-filter: grayscale(1);
  overflow-y: scroll;
}

#instructions-container {
  width: 90%;
  max-width: 600px;
  height: -webkit-fit-content;
  height: -moz-fit-content;
  height: fit-content;
  margin: calc(10px + var(--content-padding-top)) auto calc(3 * var(--content-padding-bottom)) auto;
  color: white;
  line-height: 2rem;
  font-size: 1rem;
  padding: 5px;
}

#instructions-container h2,
#instructions-container h3 {
  margin: 30px auto 5px auto;
}

#instructions-container h2 {
  text-align: center;
}

#instructions-container h3 {
  text-align: left;
}

#instructions-container hr {
  margin: 30px auto;
  height: 0.5px;
  border: none;
  color: gray;
  background-color: gray;
}

#instructions-container p {
  margin-top: 10px;
  margin-left: auto;
  margin-right: auto;
}

#debug-indicator {
  position: fixed;
  bottom: 10px;
  left: 10px;
  color: #accf97;
  pointer-events: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  text-shadow: 0px 0px 15px rgb(0 0 0 / 50%);
  font-size: 2rem;
}

@media only screen and (max-height: 900px) {

  /* On smaller devices, reduce space wasted at the top/having to scroll
  for crucial game elements. */
  :root {
    --content-padding-top: calc(var(--header-height) + 10px);
    --content-padding-bottom: 15px;
  }

  .align-children-page-center {
    justify-content: flex-start;
    height: -webkit-fit-content;
    height: -moz-fit-content;
    height: fit-content;
  }

  #message-area {
    margin: 0px auto 10px auto;
    /* Temporary to make work on small devices. */
    height: 50px;
  }
}

@media only screen and (max-width: 600px) {
  #controls {
    margin-right: 20px;
  }

  #controls span {
    margin-right: 15px;
  }
}

@media only screen and (max-width: 360px) {
  #controls {
    margin-right: 10px;
  }
}
