@font-face {
  font-family: "Source Sans 3";
  src: url("fonts/SourceSans3-VariableFont_wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --card-size: 112px;
  --gap-size: 20px;
  --flip-duration: 0.6s;
  --font-size: 14px;
}

body {
  margin: 0;
  padding: 0;
}

.block {
  position: relative;
  font-family: "Source Sans 3", sans-serif;
  width: 100%;
  height: 100%;
  /* background-color: #d1dae0; */
  background-color: #fff;
}

#game_container {
  position: relative;
  width: 100%;
  /* max-width: 100%; */
  max-width: 688px;
  height: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  /* padding: 1rem; */
  /* background: #fafafa; */
  background: #fff;
  margin-inline: auto;
  color: #000;
  box-sizing: border-box;
  /* padding-top: 20px; */
  padding-bottom: 20px;
}

#game-info {
  display: flex;
  gap: 2rem;
  font-size: var(--font-size);
  font-weight: 500;
  display: flex;
  align-items: center;
}

/* #game-info span {
  min-width: 110px;
  text-align: center;
} */

button.btn {
  font-family: "Source Sans 3", sans-serif;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 2px;
  background-color: #e8edee;
  color: #110a35;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
  font-weight: 600;
}

button.btn:hover {
  background-color: #E4E8E8;
}

.controls_top button {
  background-color: transparent;
  border: none;
  border-radius: 2px;
  height: 60px;
  font-family: "Source Sans 3", sans-serif;
  font-size: var(--font-size);
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease-in-out;
}

.controls_top button:hover {
  opacity: 0.7;
}

/* .controls_top button:hover {
  background-color: #e8edee;
} */

.fullscreen_wrapper button,
.reset_wrapper button {
  color: #000;
}

#game-board {
  display: grid;
  gap: var(--gap-size);
  justify-content: center;
  /* margin-top: 1rem; */
}

/* #game-board.finished {
  opacity: 0.3;
} */

#game_container.finished:before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #00000096;
  z-index: 2;
}

#game-board.grid_6 {
  grid-template-columns: repeat(6, var(--card-size));
}

/* #game-board {
    pointer-events: none;
} */

.card {
  width: var(--card-size);
  height: var(--card-size);
  position: relative;
  cursor: pointer;
  transition: opacity 0.15s ease-in-out;
}

.card:not(.is-flipped):hover {
  opacity: 0.7;
}

.card-inner {
  position: absolute;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform var(--flip-duration);
}

.card.is-flipped .card-inner {
  transform: rotateY(180deg);
}

.face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 12px;
  /* box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1); */
}

.front {
  transform: rotateY(180deg);
  background-size: cover;
  background-position: center;
}

.back {
  background-size: cover;
  background-position: center;
}

.layer_info {
  background-color: #fff;
  padding: 20px;
  padding-top: 20px;
  padding-bottom: 20px;
  width: 100%;
  max-width: 295px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: #000;
  padding-top: 47px;
  padding-bottom: 30px;
  box-shadow: 0 10px 21px #00000026;
  z-index: 3;
}

.score_text {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
}

.layer_info .layer_header {
  font-size: 17px;
  font-weight: 700;
  line-height: 130%;
  margin: 0;
  margin-bottom: 25px;
}

.layer_info .result_wrapper {
  display: flex;
  gap: 5px;
  margin-bottom: 10px;
}

.layer_info .result_wrapper img {
  width: 24px;
}

.layer_info .result_wrapper p {
  display: flex;
  gap: 5px;
  font-size: 14px;
  margin: 0;
}

.close_el {
  height: 24px;
  width: 24px;
  position: absolute;
  right: 8px;
  top: 8px;
  border: none;
  cursor: pointer;
  background-color: transparent;
}

.close_el:before,
.close_el:after {
  content: "";
  position: absolute;
  left: 12%;
  top: 50%;
  transform: rotate(-45deg);
  width: 20px;
  height: 2px;
  background-color: #8e8e8e;
}

.close_el:after {
  transform: rotate(45deg);
}

.close_el:hover {
  background-color: inherit;
}

.controls_top> :first-child {
  padding-left: 10px;
}

.controls_top> :last-child {
  padding-right: 10px;
}

.exitfullscreen,
.fullscreen_wrapper.full .fullscreen {
  display: none;
}

.fullscreen_wrapper.full .exitfullscreen {
  display: block;
}

.fullscreen,
#reset-btn {
  display: flex;
  align-items: center;
  gap: 5px;
}

#reset-btn span {
  white-space: nowrap;
}

.timer_wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
}

.timer_wrapper>img {
  width: 20px;
}

.controls_top {
  display: flex;
  justify-content: space-between;
  width: 100%;
  align-items: center;
  border-bottom: 1px solid #000;
  /* padding-bottom: 15px; */
}

#pause_game {
  padding-inline: 3px;
}

/* #pause_game {
    pointer-events: none;
} */

#pause_game img {
  width: 25px;
  position: relative;
  bottom: -3px;
}

#pause_game:hover {
  background-color: #e8edee;
}

#highscore,
#timer {
  white-space: nowrap;
}

.is-flipped {
  cursor: default;
}

.normal #game-board {
  gap: 15px;
  grid-template-columns: repeat(6, 98px);
}

.normal .card {
  width: 98px;
  height: 98px;
}

@media (min-width: 1828px) {
  .full #game-board {
    gap: 40px 70px;
  }

  .full .card {
    width: 170px;
    height: 170px;
  }
}

@media (min-width: 1370px) {
  .full #game-board {
    gap: 40px 70px;
  }

  .full .card {
    width: 150px;
    height: 150px;
  }
}

@media (min-width: 850px) {
  #game_container {
    max-width: 688px;
    /* max-width: 100%; */
  }
}

@media (max-width: 630px) {
  /* :root {
    --card-size: 50px;
    --gap-size: 16px;
  } */
  /* .full #game-board.grid_6 {
    grid-template-columns: repeat(4, var(--card-size));
  } */
}

/* @media (max-width: 500px) {
  :root {
    --font-size: 15px;
  }
} */

@media (max-width: 440px) {
  #game-info {
    width: 100%;
    display: flex;
    padding-inline: 14px;
    justify-content: center;
  }

  .controls_top {
    flex-wrap: nowrap;
  }
}

@media (min-width: 1368px) and (max-height: 1235px) {
  .full #game-board {
    gap: 18px 30px;
  }

  .full .card {
    width: 120px;
    height: 120px;
  }
}

@media (max-width: 860px) and (min-height: 1280px) {
  .full #game-board.grid_6 {
    grid-template-columns: repeat(4, 85px);
    gap: 13px;
  }

  .full .card {
    width: 85px;
    height: 85px;
  }
}

@media (max-width: 560px) and (min-height: 1280px) {

  /* .full #game-board {
    transform: scale(0.8);
  } */
  .full #game-board {
    /* transform: scale(0.8);
    margin-top: -40px; */
    grid-template-columns: repeat(3, 85px);
    gap: 13px;
  }

  .full .card {
    width: 85px;
    height: 85px;
  }
}

@media (max-width: 450px) and (min-height: 1280px) {

  /* .full #game-board.grid_6 {
    grid-template-columns: repeat(3, var(--card-size));
    margin-top: -190px;
    transform: scale(0.7);
  } */
  .full #game-board {
    /* transform: scale(0.8);
    margin-top: -40px; */
    grid-template-columns: repeat(3, 85px);
  }

  .full .card {
    width: 85px;
    height: 85px;
  }
}

@media (max-width: 829px) and (max-height: 900px) {

  /* .full #game-board {
    transform: scale(0.8);
    margin-top: -40px;
  } */
  .full #game-board {
    /* transform: scale(0.8);
    margin-top: -40px; */
    grid-template-columns: repeat(6, 100px);
  }

  .full .card {
    width: 100px;
    height: 100px;
  }
}

@media (max-width: 810px) and (max-height: 1277px) {
  .full #game-board {
    /* transform: scale(0.8);
    margin-top: -40px; */
    grid-template-columns: repeat(6, 100px);
  }

  .full .card {
    width: 100px;
    height: 100px;
  }
}

@media (max-width: 810px) and (max-height: 1277px) {

  /* .full #game-board {
    transform: scale(0.7);
    margin-top: -100px;
  } */
  .full #game-board {
    /* transform: scale(0.8);
    margin-top: -40px; */
    grid-template-columns: repeat(6, 85px);
  }

  .full .card {
    width: 85px;
    height: 85px;
  }
}

@media (max-width: 629px) and (max-height: 1012px) {
  /* .full #game-board {
    transform: scale(0.6);
    margin-top: -225px;
  } */

  /* .full #game-board {
    grid-template-columns: repeat(4, 65px);
    gap: 10px;
  }

  .full .card {
    width: 65px;
    height: 65px;
  } */

  .full #game-board {
    gap: 2vw;
    /* grid-template-columns: repeat(4, 65px); */
    grid-template-columns: repeat(6, calc(12vw + 10px));
  }

  .full .card {
    /* width: 65px;
    height: 65px; */
    width: calc(12vw + 10px);
    height: calc(12vw + 10px);
  }
}

@media (max-width: 460px) {
  .full #game-board {
    gap: 8px;
    grid-template-columns: repeat(4, 68px);
  }

  .full .card {
    width: 68px;
    height: 68px;
  }
}

@media (max-width: 700px) {
  .normal #game-board {
    gap: 2vw;
    /* grid-template-columns: repeat(4, 65px); */
    grid-template-columns: repeat(6, calc(12vw + 10px));
  }

  .normal .card {
    /* width: 65px;
    height: 65px; */
    width: calc(12vw + 10px);
    height: calc(12vw + 10px);
  }
}

@media (max-width: 550px) {
  .controls_top button {
    height: 45px;
  }
}

@media (max-width: 460px) {
  .controls_top {
    overflow-x: hidden;
  }
/* 
  .normal #game-board {
    gap: 8px;
    grid-template-columns: repeat(4, 68px);
  }

  .normal .card {
    width: 68px;
    height: 68px;
  } */

  .normal #game-board {
    gap: 6px;
    grid-template-columns: repeat(4, 55px);
  }

  .normal .card {
    width: 55px;
    height: 55px;
  }
}

@media (max-width: 400px) {
  #game-info {
    gap: 1rem;
    padding-inline: 0;
  }

  :root {
    --font-size: 13px;
  }
}

@media (max-width: 384px) {

  .fullscreen_wrapper button img,
  .reset_wrapper button img {
    max-width: 15px;
  }

  .controls_top> :first-child {
    padding-left: 3px;
  }

  .controls_top> :last-child {
    padding-right: 3px;
  }
}

@media (max-width: 461px) and (max-height: 677px) {
  .normal #game-board {
    gap: 6px;
    grid-template-columns: repeat(4, 55px);
  }

  .normal .card {
    width: 55px;
    height: 55px;
  }
}

#game_container.full {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  /* statt 100vh */
  z-index: 9999;
  overflow: hidden;
  background: #fff;
  /* optional */
}

.is-ios .hide-on-ios {
  opacity: 0;
  pointer-events: none;
  width: 0;
  position: absolute;
}

.is-ios .hide-on-ios+#game-info {
  justify-content: space-between;
  /* width: 30%; */
  width: calc(50% - -20px);
  padding-left: 13px;
}

@media (max-width: 550px) {
  .controls_top> :last-child {
    padding-right: 12px;
  }
}

@media (prefers-color-scheme: dark) {
  .block {
    background-color: #212529;
  }

  #game_container {
    color: #fff;
    background: #1a1d20;
    border: 1px solid #555555;
  }

  .controls_top {
    border-bottom: 1px solid #555555;
  }

  .fullscreen_wrapper button,
  .reset_wrapper button {
    cursor: pointer;
    color: #fff;
  }

  /* .controls_top button:hover {
    background-color: #343a40;
  } */

  .dark_mode {
    display: block;
  }

  .light_mode {
    display: none;
  }

  .layer_info {
    background-color: #212529;
    color: #fff;
  }

  button.btn {
    background-color: #323D46;
    color: #fff;
  }

  button.btn:hover {
    background-color: #323d46ad;
  }

  .close_el::before,
  .close_el::after {
    background-color: #fff;
  }

  #game_container.finished:before {
    content: "";
    background-color: #00000096;
  }

  .back,
  .face {
    background-size: 0 0, cover;
  }

  .is-flipped .face {
    border: 1px solid #AAAAAA;
  }

  #game_container.full {
    background: #212529;
  }
}


@media (prefers-color-scheme: light) {
  .block {
    background-color: #fff;
  }

  #game_container {
    color: #000;
    border: 1px solid #E3E3E3;
  }

  .controls_top {
    border-bottom: 1px solid #E3E3E3;
  }

  .dark_mode {
    display: none;
  }

  .light_mode {
    display: block;
  }

  #game_container.finished:before {
    content: "";
    background-color: #00000036;
  }

  .back,
  .face {
    background-size: cover, 0 0;
  }

  .is-flipped .face {
    border: 1px solid #8E8E8E;
  }
}