*::before,
*::after,
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  height: 100dvh;
}

p,
label,
#choice,
#joinServerButton,
#multiplayerButton {
  font-size: 12px;
  font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
}

p,
label {
  color: white;
}

select,
input {
  height: 25px;
}

button,
#joinServerButton,
#serverListButton,
#servers {
  cursor: pointer;
  color: black;
}

button {
  position: relative;
  cursor: pointer;
  border-width: 2px;
  border-color: black;
}

#joinServerButton:hover,
.playAgainButton:hover,
.buddyButton:hover,
.flagButton:hover,
#serverListButton:hover,
.chatButton:hover,
.minimizeChatButton:hover {
  opacity: 0.75;
}

#leaderboard {
  z-index: 100;
  color: white;
  position: absolute;
  right: 0;
  top: 0;
  /* background-color: rgba(0,0,0,0.5); */
}

#leaderboard * {
  /* font-size: 20px; */
  font-family: Verdana, Geneva, Tahoma, sans-serif;
}

#leaderboard th,
#leaderboard td {
  padding: 5px;
  text-align: left;
}

#leaderboard thead {
  background-color: rgba(0, 0, 0, 0.6);
  text-align: left;
}

#leaderboard th:nth-child(2) {
  text-align: center; /* Centering the "Wins" header */
}

#leaderboard tbody .leaderboard-player {
  background-color: rgba(0, 0, 0, 0.4);
}

#leaderboard tbody .leaderboard-player td:nth-child(2) {
  text-align: center; /* Centering the player wins data */
}

#clientUsername * {
  font-weight: bold;
}

#container {
  border: 2px solid black;
  border-radius: 7px;
  box-shadow: 7px 7px 17px black;
  position: absolute;
  top: 50%;
  /* aligns the top edge to the vertical center of the parent container */
  left: 50%;
  /* aligns the left edge to the horizontal center of the parent container */
  transform: translate(-50%, -50%);
  /* moves the div back and scales it up */
  display: grid;
  /* width: 60vw; */
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  grid-template-areas:
    "sidebar"
    "main";
  /* min-height: 44vh; */
  /* height: 44vh;   */
  grid-row-end: auto;
  overflow: visible;
}

#sidebar {
  grid-area: sidebar;
  display: grid;
  grid-template-rows: none;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  padding: 5px;
}

#serverItem {
  display: flex;
  gap: 10px;
  align-items: center;
}

#difficultySelection {
  max-width: 40%;
  justify-self: center;
}

#joinServerForm {
  display: flex;
  justify-content: end;
}
#serverCodeInput {
  width: 35%;
}

#joinServerButton {
  background-color: lightgray;
  width: 20%;
}

#joinServerButton span {
  all: unset;
  display: inline-block;
}

#joinServerButton:active span {
  transform: translate(0.35px, 0.35px);
}

#gameBoard {
  grid-area: main;
  display: grid;
  grid-template-rows: 0.1fr 1fr 0.1fr;
  grid-template-columns: 1fr;
  grid-auto-flow: column;
  align-items: center;
}

.buddyButton {
  /* width: 25px;
  height: 25px; */
  background-color: #f6cf4c;
  justify-self: center; /* Centers item along x-axis */
  align-self: center; /* Centers item along y-axis */
  margin: 10px;
}

.buddyImg {
  max-width: 100%;
}

.flagButton {
  width: 50px;
  height: 50px;
  grid-area: 3 / 4 / 3 / -2;
  background: lightgray url(../img/flag-icon.png);
  background-repeat: no-repeat;
  background-position: 50%;
  justify-self: center; /* Centers item along x-axis */
  align-self: center; /* Centers item along y-axis */
  margin: 10px;
}

button.flagButton .flagCounter {
  font-size: 10px;
  font-weight: 700;
  color: brown;
  position: absolute;
  top: 0px;
  left: 2px;
}

#gameWindow {
  margin: 0 auto;
  /* transform: scale(1.6); */
  border-spacing: 0;
  border-style: solid;
  border-color: black;
  border-width: 2px;
}

#gameWindow td {
  position: relative;
  height: 25px;
  width: 25px;
  /* font-size: 90%; */
  -webkit-text-stroke-width: 0.1px;
  -webkit-text-stroke-color: black;
  text-align: center;
  background-color: lightgray;
  border-style: solid;
  border-color: gray;
  border-width: 1px;
  font-weight: bold;
  /* font-family: 'Russo One', sans-serif; */
  font-family: "Press Start 2P", cursive;
}

.buddyButton:active,
.flagButton:active {
  transform: translate(0.35px, 0.35px);
}

#gameWindow td:hover {
  background-color: rgba(200, 200, 200, 1);
}

.playAgainButton {
  grid-area: 3 / 4 / 3 / -2; /* Next to flag button */
  max-width: 80px;
  padding: 5px;
  background-color: lightgray;
  text-align: center;
  align-items: center;
  margin-left: 58%;
  border-radius: 10px;
}

.playAgainButton:active {
  transform: translate(0.35px, 0.35px);
}

img {
  max-width: 60%;
  pointer-events: none;
}

img.flagOnMine {
  position: absolute;
  top: 30%;
  left: 20%;
  transform: translate(-50%, -50%);
  max-width: 50%;
  pointer-events: none;
}

#serverListContainer {
  all: unset;
  background-color: transparent;
  margin-top: 4px;
  height: 17px;
  width: 13px;
}

#servers {
  position: fixed;
  display: none;
  user-select: none;
}

#servers h1 {
  color: black;
  transition: color 0.1s; /* smooth transition effect */
}

#servers h1:hover {
  color: white;
  background-color: #1967d2;
}

#servers.active {
  display: flex;
  flex-direction: column;
  background-color: rgba(256, 256, 256, 0.7);
  margin-top: -1px;
  margin-left: 14px;
}

#serverListButton {
  position: relative;
}

#serverListButton.active {
  transform: rotate(360deg);
}

#servers h1 {
  padding-left: 2px;
  padding-right: 2px;
}

#enableJoinSwitch {
  --width: 50px;
  --height: calc(var(--width) / 2);
  --border-radius: calc(var(--height) / 7);

  display: inline-block;
  cursor: pointer;
}

.toggle__input {
  display: none;
}

.toggle__fill {
  position: relative;
  width: var(--width);
  height: calc(var(--height)); /* Adjust the height as needed */
  border-radius: var(--border-radius);
  background: #dddddd;
  transition: background 0.3s;
}

.toggle__input:checked ~ .toggle__fill {
  background: #4bdb63;
}

.toggle__fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: var(--height);
  background: #ffffff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.25);
  border-radius: var(--border-radius);
  transition: transform 0.2s;
}

.toggle__input:checked ~ .toggle__fill::after {
  transform: translateX(var(--height));
}

.layer * {
  /* border: 1px solid black; */
  text-align: center;
  width: 100%;
  /* Adjust the height to center the content vertically */
  height: 100%;
  display: flex !important;
  justify-content: center; /* Center horizontally */
  align-items: center; /* Center vertically */
  font-size: calc(var(--width) * 0.2); /* Adjust the factor (0.1) as needed */
}

.layer {
  display: flex;
  justify-content: center; /* Center horizontally */
  align-items: center; /* Center vertically */
  width: 100%;
  height: 100%;
}

#chatContainer {
  position: fixed;
  display: flex;
  flex-direction: column;
  bottom: 0;
  right: 0;
  margin: 20px;
  height: 450px;
}

.chatGUI {
  display: flex;
  flex-direction: column;
  height: 87%;
  width: 260px;
}

.chatGUI * {
  font-size: 17px;
}

#chatContainer .header {
  height: 30px;
  width: 100%;
  border-top-right-radius: 5px;
  border-top-left-radius: 5px;
  position: relative;
  box-shadow: 4px 4px 14px black;
}

.minimizeChatButton {
  all: unset;
  cursor: pointer;
  display: flex;
  width: 20%;
  height: 100%;
  justify-content: center;
  position: absolute;
  right: 0;
  /* background-color: red; */
}

.chatBox {
  background-color: whitesmoke;
  height: 100%;
  width: 100%;
  position: relative;
  overflow-y: auto;
  scrollbar-gutter: stable;
  box-shadow: 4px 4px 14px black;
}

.chatBoxMessages {
  margin-top: 7px;
  margin-bottom: 7px;
  /* margin-left: 17px;
  margin-right: 2px; */
  margin-left: 10px;
  margin-right: 10px;
}

.chatMessage {
  list-style-type: none;
  color: rgb(255, 255, 255);
  font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
  max-width: 70%;
  width: fit-content;
  word-break: break-word;
  /* word-break: break-word is deprecated 
  replace with  
  word-break: normal;
  and overflow-wrap: anywhere;*/
  word-break: normal;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  padding-left: 15px;
  padding-right: 15px;
  padding-top: 4px;
  padding-bottom: 4px;
  margin-bottom: 2px;
  border-top-left-radius: 15px;
  border-top-right-radius: 15px;
  scrollbar-gutter: stable both-edges;
}

/* current client's chat messages */
.chatMessage.client {
  margin-left: auto;
  border-bottom-left-radius: 15px;
  /* background-color: rgb(67, 182, 67); */
  background-color: #dd2e44;
}

/* other client's chat messages */
.chatMessage.otherClient {
  margin-right: auto;
  border-bottom-right-radius: 15px;
  background-color: #2e4add;
}

/* status messages */
.chatMessage.status,
.chatMessage.status strong {
  font-size: 12px;
  max-width: 100%;
  margin: 0 auto;
  padding-right: 0;
  padding-left: 0;
  color: rgb(34, 34, 34);
  /* background-color: red; */
}

.chatMessage.status .joined {
  color: green;
}
.chatMessage.status .left {
  color: red;
}

#chatBoxForm {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  position: sticky;
  width: 100%;
  padding: 8px;
  border-top: 1px black solid;
  background-color: rgb(219, 215, 215);
  border-bottom-right-radius: 5px;
  border-bottom-left-radius: 5px;
  box-shadow: 4px 4px 14px black;
}

#chatBoxForm input {
  width: 100%;
}

#chatBoxButton {
  padding-left: 7px;
  padding-right: 7px;
  background-color: rgb(165, 165, 165);
  color: black;
}

.chatButton {
  all: unset;
  position: absolute;
  bottom: 0;
  align-self: flex-end;
  background-color: lightblue;
  padding: 15px;
  height: 20px;
  width: 20px;
  display: flex;
  justify-content: center;
  border-radius: 15px;
  cursor: pointer;
  box-shadow: 2px 2px 4px black;
}

.chatButton:active {
  opacity: 1;
  transform: translate(0px, 0.5px);
}

.chatButton i {
  top: 24px;
  position: absolute;
}

.chatNotifyIcon {
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 12px;
  color: white;
  background-color: red;
  height: 20px;
  width: 20px;
  border-radius: 10px;
  position: absolute;
  top: -5px;
  right: -5px;
  box-shadow: 1px 1px 4px black;
}

/* Use a media query to add a break point at __ px: */
@media (min-width: 100px) {
  #container {
    width: 100vw;
    overflow: scroll;
  }
  #leaderboard {
    z-index: 100;
    right: 0%;
    font-size: 8px;
  }
  #gameWindow td {
    font-size: 30%;
    height: 12px;
    width: 12px;
  }
  #sidebar * {
    font-size: 7px;
  }
  #sidebar {
    width: 120vw;
  }
  #serverItem {
    justify-self: end;
    margin-left: 5px;
    gap: 5px;
  }
  #joinServerForm {
    justify-content: start;
    margin-right: 5px;
  }
  .buddyButton {
    width: 16px;
    height: 16px;
  }
  #gameBoard {
    grid-area: main;
    display: grid;
    grid-template-rows: 0.1fr 1fr 0.1fr;
    grid-template-columns: 1fr;
    grid-auto-flow: column;
    align-items: center;
    width: 120vw; /* Make the child grid wider than the parent container */
    overflow: scroll;
  }
  #serverListContainer {
    margin-top: 9px;
    height: 17px;
    width: 6px;
  }
  #servers.active {
    margin-top: 7px;
    margin-left: 7px;
  }
}

@media (min-width: 375px) {
  #container {
    width: 100vw;
    overflow: hidden;
  }
  #leaderboard {
    z-index: 100;
    right: 0%;
    font-size: 8px;
  }
  #gameWindow td {
    font-size: 30%;
    height: 12px;
    width: 12px;
  }
  #sidebar * {
    font-size: 8px;
  }
  #sidebar {
    width: inherit;
  }
  #serverItem {
    justify-self: end;
    gap: 5px;
  }
  #joinServerForm {
    justify-content: start;
  }
  .buddyButton {
    width: 18px;
    height: 18px;
  }
  #gameBoard {
    grid-area: main;
    display: grid;
    grid-template-rows: 0.1fr 1fr 0.1fr;
    grid-template-columns: 1fr;
    grid-auto-flow: column;
    align-items: center;
    width: inherit;
    overflow: visible;
  }
  #serverListContainer {
    margin-top: 7px;
    height: 17px;
    width: 8px;
  }
  #servers.active {
    margin-top: 8px;
    margin-left: 9px;
  }
}

@media (min-width: 425px) {
  #container {
    width: 100vw;
    overflow: hidden;
  }
  #leaderboard {
    z-index: 100;
    right: 0%;
    font-size: 9px;
  }
  #gameWindow td {
    font-size: 50%;
    height: 15px;
    width: 15px;
  }
  #sidebar * {
    font-size: 10px;
  }
  #serverItem {
    justify-self: end;
    gap: 10px;
  }
  #joinServerForm {
    justify-content: start;
  }
  .buddyButton {
    width: 20px;
    height: 20px;
  }
  #servers.active {
    margin-top: 6px;
    margin-left: 9px;
  }
}

@media (min-width: 768px) {
  #container {
    width: 100vw;
    overflow: hidden;
  }
  #leaderboard {
    -webkit-text-stroke-width: 0.3px;
    right: 0%;
    font-size: 10px;
  }
  #gameWindow td {
    font-size: 90%;
    height: 25px;
    width: 25px;
  }
  #sidebar * {
    font-size: 15px;
  }
  #serverItem {
    justify-self: end;
  }
  #joinServerForm {
    justify-content: start;
  }
  .buddyButton {
    width: 25px;
    height: 25px;
  }
  #serverListContainer {
    margin-top: 5px;
    height: 17px;
    width: 11px;
  }
  #servers.active {
    margin-top: 1px;
    margin-left: 12px;
  }
}

@media (min-width: 1020px) {
  #container {
    width: 77vw;
    overflow: hidden;
  }
  #leaderboard {
    font-size: 15px;
    right: 0;
  }
  #gameWindow td {
    font-size: 100%;
    -webkit-text-stroke-width: 0.3px;
    height: 25px;
    width: 25px;
  }
  #sidebar * {
    font-size: 15px;
  }
  #serverItem {
    justify-self: start;
  }
  #joinServerForm {
    justify-content: end;
  }
  .buddyButton {
    width: 25px;
    height: 25px;
  }
}

@media (min-width: 1100px) {
  #container {
    width: 78vw;
    overflow: hidden;
  }
  #leaderboard {
    font-size: 15px;
    right: 0;
  }
  #gameWindow td {
    font-size: 100%;
    -webkit-text-stroke-width: 0.3px;
    height: 25px;
    width: 25px;
  }
  #sidebar * {
    font-size: 15px;
  }
  #serverItem {
    justify-self: start;
  }
  #joinServerForm {
    justify-content: end;
  }
  .buddyButton {
    width: 25px;
    height: 25px;
  }
}

@media (min-width: 1440px) and (max-width: 1920px) {
  #container {
    width: 59vw;
    transform: translate(-50%, -50%) scale(1.02);
    overflow: hidden;
  }
  #leaderboard {
    font-size: 17px;
    right: 0;
  }
  #gameWindow td {
    font-size: 110%;
    -webkit-text-stroke-width: 0.3px;
    height: 27px;
    width: 27px;
  }
  #sidebar * {
    font-size: 17px;
  }
  .buddyButton {
    width: 27px;
    height: 27px;
  }
  #serverListContainer {
    margin-top: 4px;
    height: 17px;
    width: 12px;
  }
  #servers.active {
    margin-top: -1px;
    margin-left: 13px;
  }
}

@media (min-width: 1920px) and (max-width: 2560px) {
  #container {
    width: 50vw;
    transform: translate(-50%, -50%) scale(1.3);
    overflow: hidden;
  }
  #leaderboard {
    font-size: 17px;
    right: 0;
  }
  #gameWindow td {
    font-size: 110%;
    -webkit-text-stroke-width: 0.3px;
    height: 27px;
    width: 27px;
  }
  #sidebar * {
    font-size: 17px;
  }
  .buddyButton {
    width: 27px;
    height: 27px;
  }
  #serverListContainer {
    margin-top: 4px;
    height: 17px;
    width: 12px;
  }
  #servers.active {
    margin-top: -1px;
    margin-left: 13px;
  }
}

@media (min-width: 2560px) {
  #container {
    width: 40vw;
    overflow: hidden;
    transform: translate(-50%, -50%) scale(1.3);
  }
  #leaderboard {
    font-size: 20px;
    right: 0;
  }
  #gameWindow td {
    font-size: 100%;
    -webkit-text-stroke-width: 0.2px;
    height: 30px;
    width: 30px;
  }
  #sidebar * {
    font-size: 20px;
  }
  .buddyButton {
    width: 30px;
    height: 30px;
  }
  #serverListContainer {
    margin-top: 3px;
    height: 17px;
    width: 14px;
  }
  #servers.active {
    margin-top: -3px;
    margin-left: 16px;
  }
}
