:root {
  --tile-spacing: 4px;
  --total-guesses: 6;
  --max-page-width: 500px;
  --header-height: 75px;

  --color-neutral-0: #000;
  --color-neutral-10: #222;
  --color-neutral-20: #444;
  --color-neutral-100: #fff;

  --color-text: #040d14;
  --color-title: #fff;
  --color-nav: #004b84;
  --color-bg: var(--color-nav); /* match nav until theme loaded */
  --color-page-bg: var(--color-nav); /* match nav until theme loaded */
  --color-border: var(--color-neutral-10);

  --color-available: #fff;
  --color-empty: #fff;
  --color-miss: transparent;
  --color-present: #ffcb22;
  --color-match: #9fef00;

  --color-hint-text: var(--color-text);

  --color-notice-bg: var(--color-neutral-10);
  --color-notice-text: var(--color-neutral-100);
}

@media screen and (min-width: 600px) and (min-height: 400px) {
  :root {
    --header-height: 100px;
  }
}

html,
body {
  height: 100%;
}

* {
  box-sizing: border-box;
}

img {
  max-width: 100%;
  height: auto;
}

body {
  margin: 0;
  padding: 0;
  font-family: "Comic Neue", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

body.page-about,
body.page-archive,
body.page-collection,
body.page-settings {
  background: var(--color-page-bg);
}

.theme-blue {
  --color-bg: #30a3fc;
  --color-page-bg: #f0f1f3;
  --color-miss: transparent;
  --color-present: #ffcb22;
  --color-match: #9fef00;
}
.theme-high {
  --color-bg: #f0f1f3;
  --color-page-bg: var(--color-bg);
  --color-miss: #e3e4e8;
  --color-present: #86c0f9;
  --color-match: #f5793a;
}

h1,
h2,
h3,
section,
p {
  margin: 0 0 1rem;
}

p {
  line-height: 1.3;
}

header {
  height: var(--header-height);
  background-color: var(--color-nav);
  color: var(--color-title);
  position: relative;
}

header nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--color-title);
  font-weight: bolder;
  margin: 0 auto;
  max-width: var(--max-page-width);
  position: absolute;
  left: 0;
  right: 0;
  top: 35%;
  transform: translateY(-50%);
  padding: 1rem;
}

.nav-link {
  display: inline-block;
  position: relative;
  color: var(--color-bg);
  cursor: pointer;
}

.nav-notification {
  background-color: var(--color-present);
  border-radius: 50%;
  color: var(--color-text);
  padding: 0 3px;
  font-size: 10px;
  position: absolute;
  top: 0;
  right: 0;
}

.nav-tabs {
  position: absolute;
  bottom: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 4px;
  font-weight: bold;
}

.nav-tabs button {
  background: none;
  border: none;
  padding: 4px 10px;
  margin: 0;
  font: inherit;
  font-size: 0.9rem;
  border-radius: 4px 4px 0 0;
  color: var(--color-title);
}

.nav-tabs button:hover {
  cursor: pointer;
}

.nav-tabs .active {
  background-color: var(--color-bg);
  color: var(--color-text);
}

.title {
  font-size: 1.5rem;
  text-align: center;
  position: absolute;
  left: 0;
  right: 0;
  z-index: -1;
}

.title a:link,
.title a:visited {
  color: inherit;
}

@media screen and (min-width: 600px) and (min-height: 400px) {
  .title {
    font-size: 2rem;
  }
}

i {
  padding: 4px;
  vertical-align: middle;
}

a {
  text-decoration: none;
}

main {
  max-width: var(--max-page-width);
  margin: 0 auto;
  height: calc(100% - var(--header-height));
  display: flex;
  flex-direction: column;
  padding: 4px;
}

@media screen and (min-height: 400px) {
  main {
    padding: 1rem;
  }
}

.subhead {
  display: flex;
  justify-content: space-between;
}

.close-link,
.close-link:active {
  color: inherit;
}

.lowercase {
  text-transform: lowercase;
}
.uppercase {
  text-transform: uppercase;
}

.game-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-height: 80%;
  justify-content: space-between;
}

.guesses-grid {
  min-height: 0;
  padding: 8px;
  font-size: 1rem;
}

.target-4 {
  --guess-columns: 4;
}
.target-5 {
  --guess-columns: 5;
}
.target-6 {
  --guess-columns: 6;
}
.guesses-row {
  display: flex;
  justify-content: center;
  gap: var(--tile-spacing);
  aspect-ratio: var(--guess-columns, 4) / 1;
  margin: 0 auto;
  --margin-between-rows: calc(var(--total-guesses) * var(--tile-spacing));
  height: calc(calc(100% - var(--margin-between-rows)) / var(--total-guesses));
  min-height: 16px;
}

/* safari 15 etc needs this to avoid tiles enlarging */
@media not all and (min-resolution: 0.001dpcm) {
  @supports (-webkit-appearance: none) {
    .guesses-row {
      align-items: center;
    }
  }
}

.guesses-row + .guesses-row {
  margin-top: var(--tile-spacing);
}

.guesses-tile {
  flex-grow: 1;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  aspect-ratio: 1/1;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  font-size: 1em; /* inherit from font-size of .guesses-grid, set via JS */
  line-height: 1;
  background: var(--color-empty);
  transition: background linear 0.5s;
}

/* use fixed sizes for legacy safari */
@supports not (aspect-ratio: 1/1) {
  .guesses-grid {
    min-height: 280px;
  }
  .guesses-row {
    min-height: 32px;
    align-items: initial;
  }
  .guesses-tile {
    width: 58px;
    height: auto;
    flex-grow: unset;
  }

  @media only screen and (min-width: 800px) {
    .guesses-grid {
      min-height: auto;
    }
    .guesses-tile {
      width: 72px;
      height: 72px;
    }
  }
}

.keyboard {
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
}

.keyboard-row {
  user-select: none;
  display: flex;
  flex-direction: row;
  margin: 0 auto 4px;
  gap: 4px;
}

.key {
  transition: background 0.3s;
  flex-grow: 1;
  border-radius: 15px;
  background-color: var(--color-available);
  border: 2px solid var(--color-border);
  color: var(--color-text);
  cursor: pointer;
  width: 30px;
  line-height: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.key-letter {
  transition-delay: calc(0.25s * var(--guess-columns));
}
.key-enter {
  min-width: 80px;
  text-transform: capitalize;
}

@media screen and (min-height: 400px) {
  .key {
    line-height: 42px;
  }
}

@media screen and (min-width: 600px) and (min-height: 700px) {
  .keyboard {
    gap: 8px;
  }
  .key {
    line-height: 62px;
    width: 40px;
  }
  .key-letter,
  .key-back {
    font-size: 2rem;
  }
}

.key.available,
.key.present,
.key.match {
  box-shadow: rgb(0 0 0) 2px 2px;
}

.guesses-tile:nth-of-type(1) {
  transition-delay: 0s;
}
.guesses-tile:nth-of-type(2) {
  transition-delay: 0.25s;
}
.guesses-tile:nth-of-type(3) {
  transition-delay: 0.5s;
}
.guesses-tile:nth-of-type(4) {
  transition-delay: 0.75s;
}
.guesses-tile:nth-of-type(5) {
  transition-delay: 1s;
}
.guesses-tile:nth-of-type(6) {
  transition-delay: 1.25s;
}
.guesses-tile:nth-of-type(7) {
  transition-delay: 1.5s;
}
.guesses-tile:nth-of-type(8) {
  transition-delay: 1.75s;
}

.emoji-tile {
  border: none;
  background: none;
}

.emoji-image {
  filter: drop-shadow(0 0 1px var(--emoji-outline, var(--color-nav)));
}

.notice .emoji-image {
  filter: drop-shadow(0 0 0 #fff);
}

.cursor {
  box-shadow: 0 0 0 1px rgb(0 0 0), rgb(0 0 0) 3px 3px;
}

.hint-area {
  font-size: 1rem;
  font-weight: bold;
  color: var(--color-hint-text);
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 8px;
  min-height: 30px;
}
.hint-button {
  font-family: inherit;
  font-weight: bold;
  font-size: 1rem;
  appearance: none;
  background: none;
  color: inherit;
  border: none;
  cursor: pointer;
}

.victory,
.defeat {
  text-align: center;
  margin-bottom: 2rem;
}
.victory {
  font-size: 3rem;
  animation: zoom 2s ease-in 1;
}
.defeat {
  font-size: 2rem;
}

.masked-game-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.masked-game-buttons button,
.hint-area button {
  cursor: pointer;
  background-color: var(--color-empty);
  color: var(--color-text);
  border-radius: 15px;
  border: 2px solid var(--color-border);
  box-shadow: rgb(0 0 0) 2px 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 2px 8px 2px 12px;
  font-size: 1rem;
}

.masked-game-buttons button {
  width: 33%;
}

.masked-game-buttons .material-icons {
  font-size: inherit;
}

.masked-game-buttons button:hover,
.hint-area button:hover {
  outline: 2px solid var(--color-neutral-100);
}

.unavailable {
  background-color: var(--color-miss);
  cursor: auto;
}
.miss {
  background-color: var(--color-miss);
}
.present {
  background-color: var(--color-present);
}
.match {
  background-color: var(--color-match);
}

.collection-tiles {
  margin: 2rem 0;
}

.collection-tiles .emoji-tile {
  margin-right: 4px;
}

.collection-tiles .guesses-word {
  margin-bottom: 8px;
  display: flex;
  gap: 2px;
}
.example-word .guesses-word {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  gap: 2px;
}
.collection-tiles .guesses-tile,
.example-word .guesses-tile {
  flex-grow: unset;
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 1.5rem;
}

.heavy-letter {
  font-weight: bold;
}

.archive-title {
  display: none;
}

@media only screen and (min-width: 350px) {
  .archive-title {
    display: inline;
  }
}

.archive-row {
  display: flex;
  gap: var(--tile-spacing);
  padding: 2px;
}

.archive-date {
  width: 110px;
}

.archive-buttons button {
  border: 1px solid var(--color-border);
  padding: 4px 10px;
  margin: 0;
  font: inherit;
  font-size: 0.9rem;
  border-radius: 4px;
  width: 70px;
}

.archive-buttons button.unsolved {
  background-color: var(--color-empty);
}

.archive-buttons button.in-progress {
  background-color: var(--color-present);
}

.archive-buttons button.solved {
  background-color: var(--color-match);
}

.archive-buttons button:hover {
  cursor: pointer;
}

.social-links {
  margin-top: 2rem;
  display: flex;
  justify-content: center;
  gap: 16px;
}

.settings-content .sharing-theme-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.settings-content .sharing-theme-row img {
  vertical-align: middle;
}

.about-content a {
  color: inherit;
  text-decoration: underline;
}

.notice {
  position: fixed;
  top: 8%;
  bottom: auto;
  margin: 0 auto;
  left: 0;
  right: 0;
  min-width: 250px;
  width: fit-content;
  max-width: 500px;
  z-index: 1;
  text-align: center;
  align-items: center;
  border-radius: 15px;
  padding: 8px 16px;
  font-size: 1.5rem;
  color: var(--color-notice-text);
  background-color: var(--color-notice-bg);
}

/* animations */

.pulse {
  animation: grow 0.5s linear infinite alternate;
}
.pulse-small {
  animation: grow-small 0.5s linear infinite alternate;
}
.pop {
  animation: pop 0.3s;
}
.fadein {
  animation: fadein 0.5s;
}

@keyframes grow {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(1.1);
  }
}

@keyframes grow-small {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(1.05);
  }
}

@keyframes zoom {
  0% {
    transform: scale(0) rotate(-1turn);
  }
  80% {
    transform: scale(0.5) rotate(-180deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

@keyframes pop {
  from {
    transform: scale(0.8);
  }
  40% {
    transform: scale(1.2);
  }
}

@keyframes fadein {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

[x-cloak] {
  display: none !important;
}
