@import url("https://fonts.googleapis.com/css2?family=Acme&display=swap");

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  font-family: "Acme", sans-serif;
}

header {
  background-color: #47224a;
  color: #f2ebf2;
  width: 100%;
  padding-top: 1rem;
  text-align: center;
  font-family: "Acme", sans-serif;
}

header h1 {
  font-size: 2rem;
}

#subheader {
  line-height: 2rem;
  font-size: 1.3rem;
}

main {
  display: flex;
  width: 100%;
  height: fit-content;
  flex: 1;
}

/* Contains the player areas and the card area; has flex properties to be able to switch between row and column direction depending on the device */
#game-container {
  display: flex;
  flex-direction: column;
  align-self: stretch;
  justify-content: space-between;
  width: 100%;
  height: auto;
  background-color: #c9c7c9;
}

/* Player areas with player names, current turn indicator and scores */
#player-1,
#player-2 {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background-color: grey;
  flex: 1;
  align-self: stretch;
  /* Make sure the player area is always the topmost element in mobile view */
  order: 0;
  margin: 10px;
  padding: 10px;
  border-radius: 15px;
  line-height: 2rem;
  text-align: center;
  font-family: "Acme", sans-serif;
  font-size: 1.5rem;
}

/* Certain line breaks with this class will be hidden in mobile view */
.hide-on-mobile {
  display: none;
}

#player-1 p,
#player-2 p {
  flex: 1;
}

#p1-name,
#p2-name {
  font-size: 1.8rem;
}

/* This text marks the currently active player */
.active-player-note {
  font-size: 1.8rem;
  align-self: center;
  font-family: "Acme", sans-serif;
  color: #ffffff;
  text-shadow: 0 1px 5px #f8f8f8;
}

/* Empty space to push score and player name a bit further apart */
#player-1 .space,
#player-2 .space {
  flex: 3;
}

/* The card area contains the 9 cards */
#card-area {
  display: flex;
  order: 1;
  flex: 5;
  gap: 5px;
  flex-wrap: wrap;
  min-height: auto;
  align-self: stretch;
  justify-content: space-evenly;
}

/* Cards have flex properties to center the text in the middle */
.card {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  width: 25%;
  min-width: 7rem;
  margin: 10px 0;
  border-radius: 15px;
  border-style: none;
  background-color: #47224a;
  color: #f2ebf2;
  box-shadow: 0px 15px 15px rgba(71, 34, 74, 0.6),
    0px 5px 5px rgba(71, 34, 74, 0.6);
  line-height: 6rem;
  font-size: 2rem;
  font-family: "Acme", sans-serif;
  transition: all 0.3s;
}

.card:hover,
.card:focus {
  background-color: #783c7e;
  cursor: pointer;
  font-size: 2.2rem;
  transition: all 0.3s;
}

.card:focus {
  outline: 4px solid rgba(220, 197, 222, 0.5);
}

footer {
  width: 100%;
  background-color: #47224a;
  color: #f2ebf2;
  text-align: center;
  line-height: 2rem;
  font-size: 1.3rem;
  font-family: "Acme", sans-serif;
}

footer a {
  color: #f2ebf2;
}

/* Overlays the whole viewport */
#modal {
  position: fixed;
  left: 0;
  top: 0;
  height: 100%;
  width: 100%;
  background-color: rgba(201, 199, 201, 0.8);
}

#loading-screen,
#end-game-screen {
  position: relative;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  justify-content: space-between;
  /* Center the screens in the viewport */
  left: 50%;
  top: 50%;
  transform: translateX(-50%) translateY(-50%);
  width: 95%;
  height: 90vh;
  border-radius: 15px;
  border: 3px solid #3c173f;
  box-shadow: inset 0 0 5px 5px black;
  background-color: #47224a;
  color: #f2ebf2;
  padding: 1rem;
  text-align: center;
  font-family: "Acme", sans-serif;
  font-size: 1.3rem;
}

#loading-screen {
  display: flex;
}

#loading-screen h3 {
  margin-bottom: 0.5rem;
}

/* Name of the winner on the end game screen */
#winner {
  font-size: 1.7rem;
}

#end-game-screen #trophy {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 20%;
  max-width: 120px;
}

#end-game-screen .draw {
  visibility: hidden;
}

#end-game-screen table,
td,
th {
  padding: 0.5rem;
  border-collapse: collapse;
  border: none;
  font-size: 1.3rem;
}

#end-game-screen th {
  font-size: 1.5rem;
}

#end-game-screen table {
  width: 60%;
  min-width: fit-content;
  margin: auto;
}

/* Space needed to push the table to the left, so that the player names are centered on the end game screen */
#cellspace {
  width: 4.2rem;
}

/* Element below the player name input fields that is only shown on input error */
#input-error {
  height: 3rem;
  width: 100%;
  margin-bottom: -3rem;
  font-size: 0.8rem;
}

/* Player name input fields */
#player-name-inputs > p > input {
  width: 13rem;
  background-color: rgb(220, 197, 222);
  box-shadow: inset 0 -2px 2px 2px;
  border-radius: 5px;
  border-style: none;
  margin: 0.5rem 0;
  padding-left: 0.5rem;
  line-height: 2.5rem;
  font-family: "Acme", sans-serif;
  font-size: 1rem;
}

#player-name-inputs > p > input:focus {
  border-style: none;
  outline: 2px solid rgba(220, 197, 222, 0.5);
}

/* Buttons on the loading screen and end game screen */
#start-btn,
.restart-btn {
  width: 7rem;
  height: 3rem;
  background-color: rgb(220, 197, 222);
  color: #47224a;
  border-radius: 5px;
  border: none;
  margin: 4rem 0 0 0;
  font-family: "Acme", sans-serif;
  font-size: 1.5rem;
  transition: all 0.3s;
}

.restart-btn {
  height: 4rem;
  width: 7rem;
  margin: 2rem 0 0 0;
  font-size: 1.2rem;
}

#start-btn {
  margin-top: 4.4rem;
}

#start-btn:hover,
.restart-btn:hover,
#start-btn:focus,
.restart-btn:focus {
  background-color: rgb(247, 235, 247);
  font-size: 1.4rem;
  transition: all 0.3s;
}

#start-btn:hover,
#start-btn:focus {
  font-size: 1.7rem;
}

#start-btn:focus,
.restart-btn:focus {
  outline: 4px solid rgba(220, 197, 222, 0.5);
}

#start-btn:active,
.restart-btn:active {
  background-color: #47224a;
  color: rgb(247, 235, 247);
}

/* Restart button placement */
#restart-btn-div {
  display: flex;
  justify-content: space-evenly;
}

/* Div containing the paragraphs with the question and the answers */
#quiz-card {
  position: fixed;
  display: none;
  flex-direction: column;
  justify-content: space-between;
  /* Centered in the middle of the viewport */
  left: 50%;
  top: 50%;
  transform: translateX(-50%) translateY(-50%);
  width: 100%;
  min-width: 200px;
  height: 95vh;
  /* Become scrollable in case it doesn't fully fit */
  overflow-y: auto;
}

/* Shared styles for all paragraphs on the quiz card */
.qcard-text {
  display: flex;
  /* Make sure the text is centered vertically and horizontally */
  justify-content: center;
  align-items: center;
  text-align: center;
  border-radius: 10px;
  border-style: none;
  background-color: #47224a;
  color: #f2ebf2;
  margin: 0 7px 3px 7px;
  padding: 1rem 0.5rem 1rem 0.5rem;
  font-family: "Acme", sans-serif;
  font-size: 1.5rem;
}

.question {
  flex: 3;
  background-color: #271328;
}

.answer {
  flex: 1;
  margin: 0 7px 7px 7px;
  box-shadow: 0px 6px 6px rgba(75, 21, 78, 0.8),
    0px 3px 6px rgba(195, 137, 199, 0.6);
  transition: all 0.3s;
}

.answer:hover,
.answer:focus {
  background-color: #783c7e;
  color: #f2ebf2;
  cursor: pointer;
}

.answer:focus {
  outline: 2px solid rgba(220, 197, 222, 0.5);
}

#close-card {
  flex: 1;
  padding: 0.5rem 0 0.5rem 0;
  margin: 0 7px 5px 7px;
  border-radius: 10px;
  border: none;
  background-color: #271328;
  color: #271328;
  font-family: "Acme", sans-serif;
  line-height: 2.7rem;
  font-size: 1.5rem;
  transition: all 0.3s;
  pointer-events: none;
}

#close-card:hover,
#close-card:focus {
  background-color: #783c7e;
  font-size: 1.7rem;
  transition: all 0.3s;
}

#close-card:focus {
  outline: 2px solid rgba(220, 197, 222, 0.5);
}

/* Styles for the error pages error.html and 404.html, centers the content on the viewport */
#error-page-div {
  font-size: 2rem;
  display: block;
  margin: auto;
  padding: 2rem;
}

#error-page-div ul {
  padding: 1rem;
  font-size: 1.5rem;
}

/* Media query for small screens, making sure certain graphics are not visible unless there is sufficient space for them */
@media screen and (min-width: 497px) {
  #end-game-screen .draw {
    visibility: visible;
  }
}

/* Media query for view on rotated phones and small tablets */
@media screen and (min-width: 769px) {
  #show-on-mobile {
    display: none;
  }

  .hide-on-mobile {
    display: initial;
  }

  #game-container {
    flex-direction: row;
  }

  #player-1,
  #player-2 {
    min-height: 60vh;
    line-height: 3.5rem;
    font-size: 2rem;
    order: initial;
  }

  #p1-name,
  #p2-name {
    font-size: 2rem;
  }

  #card-area {
    order: initial;
  }

  #loading-screen,
  #end-game-screen {
    display: none;
    width: 70%;
    min-width: 500px;
    height: 70vh;
    padding: 1rem 2rem;
    font-size: 1.3rem;
  }

  #loading-screen {
    display: flex;
  }

  #input-error {
    font-size: 1rem;
  }

  #player-name-inputs {
    columns: 2 auto;
  }

  #player-name-inputs > p > input {
    margin-top: 1rem;
    font-size: 1.5rem;
  }

  #start-btn {
    margin-top: 4rem;
  }

  #start-btn:hover,
  #start-btn:focus,
  .restart-btn:hover,
  .restart-btn:focus {
    font-size: 1.7rem;
  }

  #quiz-card {
    width: 47%;
    height: 90vh;
  }

  .qcard-text {
    font-size: 1.5rem;
  }

  .question {
    padding: 1.5rem;
  }

  #close-card {
    font-size: 1.6rem;
  }

  #close-card:hover,
  #close-card:focus {
    font-size: 1.7rem;
  }

  #winner {
    font-size: 2.5rem;
  }

  #end-game-screen table,
  td,
  th {
    font-size: 1.5rem;
  }

  #end-game-screen th {
    font-size: 1.8rem;
  }

  #end-game-screen table {
    width: 50%;
  }

  .restart-btn {
    width: 10rem;
    font-size: 1.5rem;
  }
}

/* Media query for view on screens > 862px */
@media screen and (min-width: 862px) {
  #p1-name,
  #p2-name {
    font-size: 2.4rem;
  }

  #loading-screen,
  #end-game-screen {
    width: 70%;
    height: 75vh;
    padding: 1.5rem 3rem;
    font-size: 1.4rem;
  }
}

/* Media query for view on laptops and screens > 1440px */
@media screen and (min-width: 1440px) {
  header h1 {
    font-size: 3rem;
  }

  #subheader {
    font-size: 2rem;
  }

  #player-1,
  #player-2 {
    font-size: 2.5rem;
    line-height: 4rem;
  }
  #p1-name,
  #p2-name {
    font-size: 3rem;
  }

  .active-player-note {
    font-size: 2.5rem;
  }

  .card {
    font-size: 3rem;
  }

  .card:hover,
  .card:focus {
    font-size: 3.2rem;
  }

  #quiz-card {
    width: 43%;
    height: 85vh;
  }

  .qcard-text {
    font-size: 2rem;
  }

  .question {
    padding: 2rem;
  }

  #close-card {
    font-size: 2rem;
  }

  #close-card:hover,
  #close-card:focus {
    font-size: 2.2rem;
  }

  #loading-screen,
  #end-game-screen {
    width: 60%;
    height: 70vh;
    padding: 1.5rem 3rem;
    font-size: 1.8rem;
  }

  #end-game-screen {
    height: 75vh;
  }

  #input-error {
    font-size: 1.2rem;
  }

  #start-btn {
    height: 4rem;
    width: 10rem;
    margin-top: 4rem;
    font-size: 2.2rem;
  }

  #start-btn:hover,
  #start-btn:focus {
    font-size: 2.5rem;
  }

  .restart-btn {
    width: 14rem;
    font-size: 2rem;
  }

  .restart-btn:hover,
  .restart-btn:focus {
    font-size: 2.2rem;
  }
}

/* Media query for view on larger screens > 2559px */
@media screen and (min-width: 2559px) {
  header h1 {
    font-size: 3rem;
  }

  #subheader {
    font-size: 2rem;
  }

  #player-1,
  #player-2 {
    font-size: 3.5rem;
    line-height: 5rem;
  }

  #p1-name,
  #p2-name {
    font-size: 3.5rem;
  }

  .active-player-note {
    font-size: 2.5rem;
  }

  .card {
    font-size: 3.5rem;
  }

  .card:hover,
  .card:focus {
    font-size: 3.7rem;
  }

  #quiz-card {
    width: 33%;
    height: 80vh;
  }

  .qcard-text {
    font-size: 2.5rem;
  }

  .question {
    padding: 3rem;
  }

  #close-card {
    font-size: 2.5rem;
  }

  #close-card:hover,
  #close-card:focus {
    font-size: 2.7rem;
  }

  #loading-screen,
  #end-game-screen {
    width: 50%;
    height: 70vh;
    padding: 2rem 3rem;
    font-size: 2rem;
  }

  #end-game-screen {
    height: 75vh;
  }

  #end-game-screen table,
  td,
  th {
    font-size: 1.8rem;
  }

  #end-game-screen th {
    font-size: 2.2rem;
  }

  #player-name-inputs > p > input {
    width: 20rem;
    height: 4rem;
    font-size: 2rem;
  }

  #input-error {
    font-size: 2rem;
  }

  #start-btn {
    height: 5rem;
    width: 15rem;
    margin-top: 6rem;
    font-size: 3rem;
  }

  #start-btn:hover,
  #start-btn:focus {
    font-size: 3.3rem;
  }

  .restart-btn {
    width: 17rem;
    font-size: 2.2rem;
  }

  footer {
    line-height: 2.8rem;
    font-size: 2.5rem;
  }
}
