:root {
	--case-size: 100px;
	--whiteCase: #dcdcdc;
	--blackCase: #666666;
}

@font-face {
  font-family: 'Bungee Spice';
  src: url('fonts/bungee-spice.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

body {
	font-family: Arial, sans-serif;
	margin: 0;
	padding: 5px;
  color: white;
	background-color: #333;
}

a {
  text-decoration: none;
  color: white;
}

a:visited {
  color: inherit;
}

h1 {
	font-family: "Bungee Spice", sans-serif;
	text-align: center;
  cursor: pointer;
	margin: 10px 0px 0px 0px;
}

#roomWrapper {
	display: flex;
	justify-content: center;
	align-items: center;
}

#inputWrapper {
  display: flex;
}

#roomCode,
#pseudo {
  display: block;
  margin: 15px;
  padding: 10px 15px;
  width: 250px;
  font-size: 20px;
  border: none;
  border-radius: 8px;
  outline: none;
  color: white;
  background-color: #121212;
  -webkit-transition: box-shadow 0.3s ease;
  transition: box-shadow 0.3s ease;
}

#roomCode:focus,
#pseudo:focus {
  box-shadow: 0 0 8px rgba(255, 165, 0, 8);
  -webkit-box-shadow: 0 0 8px rgba(255, 165, 0, 8);
}

#roomButton,
#modalCloseButton {
  display: block;
  margin: 10px;
  padding: 12px 25px;
  font-size: 18px;
  font-weight: bold;
  background-color: #ff6600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  -webkit-transition: background-color 0.3s ease, transform 0.1s ease;
  transition: background-color 0.3s ease, transform 0.1s ease;
}

#roomButton:hover,
#modalCloseButton:hover {
  background-color: #ff8400;
  -webkit-background-color: #ff8400;
}

#roomButton:active,
#modalCloseButton:active {
  transform: scale(0.975);
  -webkit-transform: scale(0.975);
}

#gameInfo {
  display: none;
  flex-direction: row;
  align-items: center;
  margin-top: 20px;
  gap: 20px;
  color: var(--white);
  font-size: 20px;
  background-color: #444;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 0 10px rgba(255, 165, 0, 0.5);
  -webkit-box-shadow: 0 0 10px rgba(255, 165, 0, 0.5);
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

#roomCodeDisplay {
  position: absolute;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  top: 10px;
  right: 10px;
  background-color: #222;
  padding: 8px 12px;
  color: var(--white);
  font-weight: bold;
  box-shadow: 0 0 6px rgba(255, 255, 255, 1);
  -webkit-box-shadow: 0 0 6px rgba(255, 255, 255, 1);
  z-index: 9999;
  filter: contrast(115%);
  -webkit-filter: contrast(115%);
}

#skinsButton {
  position: absolute;
  cursor: pointer;
  top: 10px;
  left: 10px;
  background-color: #222;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--white);
  font-weight: bold;
  font-size: 18px;
  box-shadow: 0 0 6px rgba(255, 255, 255, 1);
  -webkit-box-shadow: 0 0 6px rgba(255, 255, 255, 1);
  z-index: 9999;
}

#playersDisplay,
#turnDisplay,
#playerTurnDisplay {
  padding: 8px 16px;
  background-color: #555;
  border-radius: 8px;
  font-size: 20px;
  font-weight: bold;
  text-align: center;
  width: 100%;
}

.chessGrid {
	display: grid;
	grid-template-columns: repeat(8, var(--case-size));
	grid-template-rows: repeat(8, var(--case-size));
	width: calc(var(--case-size) * 8);
	border: 2px solid white;
	margin: 25px calc(50% - (var(--case-size) * 8) / 2 - 2px);
}

.case {
	display: flex;
}

.case img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.white {
  background-color: var(--whiteCase);
}

.black {
  background-color: var(--blackCase);
}

.available {
  background-color: rgba(255, 0, 0, 0.2);
}

.ready {
  margin-bottom: 20px;
}

#skinsModal {
  display: flex;
  flex-direction: column;
  position: fixed;
  width: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  -webkit-transform: translate(-50%, -50%);
  padding: 15px;
  background-color: #222;
  border: 2px solid white;
  border-radius: 25px;
  box-shadow: 0 0 10px rgba(255, 255, 255, 1);
  -webkit-box-shadow: 0 0 10px rgba(255, 255, 255, 1);
  z-index: 9999;
}

.modalSkinsTitle {
	font-family: "Bungee Spice", sans-serif;
	text-align: center;
  margin: 0px;
}

.gridSkins {
  display: flex;
  justify-content: center;
  flex-direction: row;
  gap: 10px;
  margin: 10px;
}

.gridSkins img {
  width: 70px;
  object-fit: contain;
  border: 2px solid white;
}

#activeSkinWhite,
#activeSkinBlack {
  box-shadow: 0 0 10px rgb(0, 255, 255, 1);
  -webkit-box-shadow: 0 0 10px rgba(0, 255, 255, 1);
}

#gameOverModal {
  display: flex;
  flex-direction: column;
  position: fixed;
  width: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  -webkit-transform: translate(-50%, -50%);
  padding: 30px;
  background-color: #222;
  border: 2px solid white;
  border-radius: 25px;
  box-shadow: 0 0 10px rgba(255, 255, 255, 1);
  -webkit-box-shadow: 0 0 10px rgba(255, 255, 255, 1);
  z-index: 9999;
}

#modalTitle {
  text-align: center;
  margin: 0px;
}

#modalResultText {
  text-align: center;
  font-size: 20px;
}

/* Media Queries */

@media (max-width: 1440px) {
  :root {
    --case-size: 85px;
  }
}

@media (max-width: 1024px) {
  :root {
    --case-size: 75px;
  }
}

@media (max-width: 850px) {
  :root {
    --case-size: 65px;
  }

  #roomWrapper {
    display: flex;
    flex-direction: column;
  }

  #inputWrapper {
    display: flex;
  }

  #roomCodeDisplay {
    font-size: 16px;
  }

  #playersDisplay,
  #turnDisplay,
  #playerTurnDisplay {
    font-size: 16px;
  }

  #roomCode,
  #pseudo {
    width: 225px;
    font-size: 18px;
  }
}

@media (max-width: 650px) {
  :root {
    --case-size: 55px;
  }

  h1 {
    font-size: 24px;
  }

  #roomCodeDisplay {
    font-size: 14px;
  }

  #playersDisplay,
  #turnDisplay,
  #playerTurnDisplay {
    font-size: 14px;
  }

  #roomCode,
  #pseudo {
    width: 150px;
    font-size: 16px;
  }
}

@media (max-width: 550px) {
  :root {
    --case-size: 45px;
  }

  h1 {
    font-size: 22px;
  }

  #skinsButton {
    top: 10px;
    left: 10px;
    padding: 8px 8px;
    font-size: 16px;
  }

  #roomCode,
  #pseudo {
    width: 120px;
    font-size: 14px;
  }

  #roomButton,
  #modalCloseButton {
    margin: 8px;
    padding: 10px 20px;
    font-size: 16px;
  }

  #gameInfo.ready {
    display: grid !important;
    gap: 10px;
  }

  #roomCodeDisplay {
    position: initial;
    text-align: center;
  }

  #playersDisplay,
  #turnDisplay,
  #playerTurnDisplay {
    width: auto;
    font-size: 18px;
  }

  .chessGrid {
    margin-top: 10px;
  }
}

@media (max-width: 400px) {
  :root {
    --case-size: 40px;
  }

  h1 {
    font-size: 20px;
  }

  #skinsButton {
    top: 5px;
    left: 5px;
    padding: 5px 5px;
    font-size: 14px;
  }

  #roomButton,
  #modalCloseButton {
    margin: 5px;
    font-size: 14px;
  }

  #gameInfo.ready {
    margin-left: 20px;
    margin-right: 20px;
  }
}

@media (max-width: 350px) {
  :root {
    --case-size: 35px;
  }

  h1 {
    font-size: 18px;
  }

  #skinsButton {
    font-size: 12px;
  }

  #roomCode,
  #pseudo {
    width: 110px;
    margin: 10px;
  }
}

/* Keyframes */

@keyframes dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
  100% { content: ''; }
}

@-webkit-keyframes dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
  100% { content: ''; }
}

.dots::after {
  content: '';
  -webkit-animation: dots 1s steps(4, end) infinite;
  animation: dots 1s steps(4, end) infinite;
}
