/* Root and body */
*
{
  box-sizing: border-box;
  font-family: Verdana, arial, sans-serif;
}

/* Variables */
:root {
  --lime-green: #3d8e3d;
  --dark-gray: #333;
  --yellow: #9e8c3f;
}

html, body
{
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  background-color: #111;
  color: #eee;
  font-size: 16px;
  overflow: hidden;
}

body
{
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 100%;
}
body > div { /* Three-column body layout */
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

/* Responsive changes */

/* MOBILE AND TABLET */
@media (max-width: 1024px)
{

  body {
    grid-template-columns: 50% 50% !important;
    grid-template-rows: 100% !important;
  }

  /* Hide leaderboard menu by default */
  #show-social-menu {
    display: block !important;
    margin: 1rem;
  }

  #close-social-menu {
    display: block !important;
    padding: 1rem 2rem;
    font-size: 1.4rem;
    margin: 4rem auto;
    border-radius: 15px;
  }
  #close-social-menu:hover {
    opacity: 0.8;
    cursor: pointer;
  }

  #social-menu {
    display: none;
    grid-column: span 2 !important;
    margin: auto;
    width: 90%;
    height: 99vh;
    padding: 1rem;
    border-bottom: 1px solid #eee;
  }
  #leaderboard {
    width: 100% !important;
    height: 60% !important;
    margin: auto !important;
  }
}

/* MOBILE: 600px or <600px */
@media (max-width: 700px)
{

  html, body {
    font-size: 15px; /* Smaller font */
  }

  body {
    display: flex;
    flex-direction: column;
  }

  /* Horizontal row for mobile screens */
  .sidebar-wrapper {
    display: flex !important;
    width: 100% !important;
    margin: auto;
  }

  #sidebar {
    display: flex;
    flex-direction: row;
    padding: 0;
    margin: 0;
    min-width: 100%;
    align-content: space-between;
    justify-content: center;
  }

  #sidebar > * {
    flex-direction: row;
    gap: 0;
    align-items: center;
  }

  .score, #difficulty {
    font-size: 1.1rem !important;
  }

  .score * {
    padding: 0.25rem !important;
    font-size: 1rem !important;
  }

  #show-difficulty-note {
    display: block !important;
  }

  .note {
    display: none; /* Hide notice about difficulty on mobile */

    /* Custom styling for difficulty notice on mobile */
    flex-direction: column;
    position: absolute;
    max-width: 6rem;
    transform: translate(75%, -75%);
    background: #eee;
    color: #000;
    padding: 0.5rem !important;
    border-radius: 5px;
    box-shadow: -1px -1px 5px 1px #555;
  }

  .guess-row {
    margin: 0.1rem !important;
    gap: 0.1rem !important;
  }

  #guess-keyboard {
    max-width: 100% !important;
  }

  .guess-key
  {
    font-size: 2rem !important;
  }

  /* Custom design for timers on mobile with absolute pos */
  #timer {
    position: absolute;
    top: 10px;
    left: 45px;
    border: 2px solid white;
    margin: 0 1rem !important;
    padding: 0.25rem;
    border-radius: 5px;
  }

  .logo { /* Smaller logo */
    width: 6rem !important;
  }

  #popup {
    font-size: 1.25rem !important;
    min-width: 50% !important;
    max-height: 40% !important;
    max-width: 80% !important;
    padding: 6rem 4rem !important;
  }

  .more-info {
    font-size: 0.5rem !important;
  }
  .more-info img {
    transform: scale(0.75);
  }

  /* Chat should be positioned center bottom and hidden by default */
  .chat-wrapper
  {
    position: absolute;
    bottom: 0;
    height: 40vh;
    max-height: 40vh !important;
    background: #000000e5;
    transform: translateY(-25%);
    transition: transform 0.5s ease-out;
    padding: 1rem !important;
    border-radius: 15px;
    z-index: 1;
  }
  .chat-wrapper.hide {
    transform: translateY(40vh) !important;
  }
  #toggle-chat {
    right: 50% !important;
    transform: translate(50%, -300%);
  }

  .lobby-users
  {
    display: none;
  }
}

/* TABLET: >768px AND <1024px */
@media (min-width: 700px) and (max-width: 1024px)
{

  /* 50 / 50 style grid */
  body {
    padding: 0;
    grid-template-columns: 65% 25%;
    grid-template-rows: 100%;
  }

  .logo {
    width: 8rem !important; /* Smaller logo */
  }

  .sidebar-wrapper {
    grid-template-columns: 50% 50% !important;
    column-gap: 1rem !important;
  }

  #sidebar {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    align-content: center;
  }

  #sidebar > * {
    display: flex;
    justify-content: center;
    width: 100%;
    gap: 1rem;
    align-items: center;
  }

  /* Don't stretch keyboard and bigger keys */
  .guess-key
  {
    font-size: 1.8rem !important;
  }

  /* Custom design for timers on mobile with absolute pos */
  #timer {
    font-size: 1.8rem !important;
    border: 2px solid white;
    margin: 0 !important;
    padding: 0.25rem;
    border-radius: 5px;
  }

  .button {
    width: 3rem !important;
    height: auto !important;
  }

  #popup {
    font-size: 1.4rem !important;
    min-height: 50% !important;
    min-width: 40% !important;
    max-width: 70% !important;
    padding: 6rem 4rem !important;
  }

  .chat-wrapper
  {
    max-width: 100% !important;
  }

  .chat-controls {
    flex-direction: column !important;
    width: 100% !important;
  }

  .chat-controls > * {
    font-size: 0.8rem !important;
    text-align: center;
  }

}

/* Central gameplay main */
main
{
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 auto;
  width: 90%;
  min-height: 60%;
}

/* Header with title */
header
{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  font-size: 1.2rem;
}

/* Leaderboard button */
#show-social-menu
{
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 2rem;
  height: 2rem;
  filter: contrast(0) brightness(2);
}
#show-social-menu:hover {
  filter: contrast(0) brightness(1.5) !important;
  cursor: pointer;
}

#close-social-menu {
  display: none;
}

/* Displays the actual word on failure */
#real-word
{
  font-size: 1.3rem;
  text-transform: uppercase;
  letter-spacing: 3px;
}

/* Sidebar with stats */

.sidebar-wrapper
{
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 5rem;
  max-width: 85%;
  height: 90%;
  padding: 0.5rem;
}
.sidebar-wrapper > * {
  margin: 0 auto;
}

aside
{
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 75%;
}
aside > div {
  margin: 1rem auto;
}

/* Chat messages */
.chat-wrapper
{
  padding: 2rem 0;
  display: grid;
  grid-template-rows: 2% 90% 8%;
  grid-template-columns: 100%;
  max-height: 100%;
  row-gap: 1rem;
}

#toggle-chat
{
  visibility: visible !important;
  position: fixed;
  top: 10px;
  right: 15px;
  font-size: 0.9rem;
  font-weight: bold;
  text-decoration: underline;
}
#toggle-chat:hover
{
  opacity: 0.8;
  cursor: pointer;
}

#chat-messages
{
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  grid-row: 1 / span 2;
  overflow: hidden scroll;
  overflow-wrap: anywhere;
  max-width: 100%;
  text-wrap: wrap;
  gap: 1rem;
  padding: 1rem;
  text-align: left;
  border: 1px solid #eee;
  border-radius: 5px;
  font-size: 1rem;
  list-style-position: inside;
  list-style-type: none;
}

.chat-controls
{
  display: flex;
  flex-direction: row;
}

.chat-controls > * {
  font-size: 1rem;
  padding: 0.5rem;
}

/* Leaderboard display */
#leaderboard
{
  margin: auto 0 auto auto;
}

#leaderboard > h1 {
  font-size: 1.1rem;
  font-weight: bold;
}

#leaderboard-list {
  min-height: 40%;
  text-align: left;
  list-style-position: outside;
  list-style-type: decimal;
  font-size: 1rem;
}

.leaderboard-entry {
  transition: opacity 0.5s ease-in-out;
  height: 25px;
}
.leaderboard-entry:hover {
  color: #ddd;
}
.leaderboard-entry.fade-out {
  opacity: 0;
}
.leaderboard-entry.fade-in {
  opacity: 1;
}

/* Username setting */
.username-wrapper
{
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 10%;
  width: 100%;
  gap: 0.25rem;
}

.username-wrapper > * {
  font-size: 1rem;
  padding: 0.5rem;
  border-radius: 0.5rem;
  text-align: center;
}

.username-wrapper p {
  font-size: 0.8rem;
  color: #dd3030;
}

/* Difficulty setting */
.settings
{
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.settings select
{
  padding: 0.5rem;
  font-size: 1rem;
  color: #ddd;
  border: none;
  background-color: #444;
  border-radius: 5px;
  box-shadow: -1px -1px 1px 2px #101010;
}

.controls
{
  margin: 2rem;
  display: flex;
  justify-content: center;
}

/* Difficulty notice message */
#show-difficulty-note
{
  /* Button not necessary on desktop */
  display: none;

  filter: contrast(0) brightness(2);
  width: 1.5rem;
  height: auto;
  margin: 0 0.25rem;
}
#show-difficulty-note:hover {
  opacity: 0.8;
  cursor: pointer;
}

.note
{
  padding: 0.25rem;
  font-size: 0.75rem;
}

/* Popup for a message */
.popup-overlay
{
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #00000030;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity 1s ease;
}
#popup
{
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 3rem 2rem;
  justify-content: center;
  align-content: center;
  text-align: center;
  transform: translateY(-20%);
  min-width: 6%;
  min-height: 4%;
  max-width: 20%;
  max-height: 30%;
  background-color: #333;
  font-size: 1rem;
  color: #eee;
  border-radius: 15px;
  box-shadow: -1px -1px 5px 1px #111;
  transition: opacity 1s ease;
}

#popup-buttons
{
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-evenly;
  gap: 1rem;
  margin: 2rem auto 0 auto;
  width: 100%;
  height: 2rem;
}

.button {
  height: 2rem;
  width: auto;
  filter: contrast(0) brightness(2);
  transition: transform 0.3s ease-in-out;
}
.button:hover {
  opacity: 0.8;
  cursor: pointer;
  transform: scale(1.1);
}

/* Guess keyboard display */
#guess-keyboard
{
  display: flex;
  flex-direction: column;
  max-width: 75%;
  min-height: 18%;
  gap: 1rem;
  margin: 1rem;
}

.guess-keyboard-row
{
  margin: auto;
}

.guess-key
{
  padding: 0.25rem;
  margin: auto 0.05rem;
  font-size: 1.25rem;
  background-color: #555;
  border-radius: 5px;
}
.guess-key:hover {
  opacity: 0.8;
  cursor: pointer;
}
.guess-key.correct {
  background-color: var(--lime-green);
}
.guess-key.possible {
  background-color: var(--yellow);
}
.guess-key.incorrect {
  background-color: var(--dark-gray);
}

/* Time left */
#timer {
  text-align: center;
  margin: 3rem;
  font-size: 1.25rem;
}

/* Score / points display */
.score
{
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 1.25rem;
}
.score > span {
  padding: 0.5rem;
  font-size: 2rem;
}
#highscore {
  font-size: 1.9rem;
}
#clear-highscore {
  width: 1rem !important;
  height: auto !important;
  margin: 0.25rem;
}
#clear-highscore:hover {
  animation: spin 1s ease-out 1;
}

/* Individual rows of guesses */
.guess-row
{
  margin: 0.5rem auto;
  display: grid;
  grid-template-rows: 3.5rem;
  grid-template-columns: repeat(5, 3.5rem);
  grid-column-gap: 0.5rem;
  width: 100%;
}

.guess-letter /* Each letter cell */
{
  display: flex;
  width: 100%;
  height: 100%;
  border: 2px solid #444;
  font-size: 2rem;
  font-weight: bold;
}
/* Individual cell colouring */
.guess-letter > * { margin: auto; }
.guess-letter.correct { color: #ddd; background-color: var(--lime-green); animation: bounce 0.5s 1; }
.guess-letter.possible { color: #ddd; background-color: var(--yellow); animation: bounce 0.5s 1; }
.guess-letter.incorrect { color: #ddd; background-color: var(--dark-gray); animation: bounce 0.5s 1; }

/* Keyboard guess input info message */
#guess-input-info
{
  font-size: 0.75rem;
  transition: opacity 1s ease-in-out;
  opacity: 1;
}
#guess-input-info.hidden
{
  opacity: 0;
}

/* Active users in the lobby */
.lobby-users
{
  font-size: 1rem;
}
#lobby-active-users
{
  font-weight: bold;
}
#lobby-users-list
{
  text-align: center;
  width: 100%;
  display: flex;
  flex-direction: column;
}
#lobby-users-list > * {
  margin: 0.25rem auto;
}

/* Keyboard guess input */
#guess-input
{
  font-size: 1.4rem;
  margin: 1.5rem auto;
  padding: 0.25rem;
  text-align: center;
  width: max-content;
}
#guess-input.is-selected {
  border-color: #ddd;
  box-shadow: 0 0 2px #eeeeeea0;
}
#guess-input:hover {
  background-color: #222;
}

/* Logo */
.logo
{
  position: absolute;
  bottom: 15px;
  left: 15px;
  width: 12rem;
  height: auto;
  filter: brightness(0.75);
}

/* Version # */
.more-info
{
  display: flex !important;
  width: min-content;
  height: auto;
  font-size: 1rem;
  position: absolute;
  right: 10px;
  bottom: 10px;
  flex-direction: row !important;
  align-items: center;
  gap: 2rem;
}

.more-info img
{
  width: 2rem;
  height: auto;
  filter: contrast(0) brightness(2);
}

/* Animations */
@keyframes bounce {
  from {
    scale: 1;
  }
  50% {
    scale: 1.1;
  }
  to {
    scale: 1;
  }
}

@keyframes normal-scale {
  0% {
  }
  100% {
    transform: scale(1);
  }
}

@keyframes scale-up {
  from {
    scale: 1;
  }
  to {
    scale: 1.1;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}


