body {
  font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
  background: #121213;
  color: #f3f3f3;
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
h1{
  font-family: "Arial Black", Gadget, sans-serif;
font-size: 25px;
letter-spacing: -1.6px;
word-spacing: 2px;
text-align: center;
font-weight: 700;
text-decoration: underline solid rgb(68, 68, 68);
font-style: normal;
font-variant: normal;
text-transform: uppercase;
}
h5{
  font-family: "Arial Black", Gadget, sans-serif;
text-align: center;
font-weight: 700;
text-decoration: underline solid rgb(68, 68, 68);
font-style: normal;
font-variant: normal;
}
#app {
  margin-top: 32px;
  padding: 32px 40px 24px 40px;
  background: #1a1a1b;
  border-radius: 16px;
  box-shadow: 0 6px 36px #000b;
  width: 480px;
  max-width: 98vw;
}

h2 {
  letter-spacing: 0.05em;
  font-weight: 700;
  font-size: 2.1em;
  margin-bottom: 0.5em;
  color: #f3f3f3;
  text-align: center;
}

#game-board {
  display: grid;
  grid-template-rows: repeat(6, 56px);
  grid-template-columns: repeat(5, 56px);
  gap: 8px;
  margin: 18px 0 12px 0;
  justify-content: center;
}
.row {
  display: contents;
}

.tile {
  width: 56px;
  height: 56px;
  font-size: 2.2em;
  font-weight: 900;
  background: #121213;
  border: 2.5px solid #3a3a3c;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  text-transform: uppercase;
  box-sizing: border-box;
  transition: background 0.2s, border 0.2s, color 0.2s;
  user-select: none;
  letter-spacing: 0.03em;
  outline: none;
}

.correct {
  background: #538d4e;
  border-color: #538d4e;
  color: #fff;
}
.present {
  background: #b59f3b;
  border-color: #b59f3b;
  color: #fff;
}
.absent {
  background: #3a3a3c;
  border-color: #3a3a3c;
  color: #565758;
}
.tile.filled {
  border-color: #565758;
  animation: pop 0.13s;
}
@keyframes pop {
  0% { transform: scale(1);}
  50% { transform: scale(1.16);}
  100% { transform: scale(1);}
}

@keyframes flipIn {
  0% { transform: rotateX(0);}
  50% { transform: rotateX(90deg);}
  100% { transform: rotateX(0);}
}
.tile.flip {
  animation: flipIn 0.6s;
  animation-timing-function: cubic-bezier(.68,-0.55,.27,1.55);
}
.row.win .tile {
  animation: bounce 0.7s;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0);}
  30% { transform: translateY(-18px);}
  50% { transform: translateY(6px);}
  70% { transform: translateY(-3px);}
}
.row.lose .tile {
  animation: shake 0.7s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0);}
  20%, 60% { transform: translateX(-10px);}
  40%, 80% { transform: translateX(10px);}
}

#keyboard {
  margin: 24px 0 8px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.kb-row {
  display: flex;
  gap: 6px;
}
.kb-key {
  width: 43px;
  height: 58px;
  border-radius: 4px;
  background: #818384;
  color: #fff;
  font-weight: 700;
  font-size: 1.18em;
  text-align: center;
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
  user-select: none;
  margin-bottom: 0;
  text-transform: uppercase;
  box-sizing: border-box;
  letter-spacing: 0.01em;
}
.kb-key.correct { background: #538d4e; }
.kb-key.present { background: #b59f3b; }
.kb-key.absent { background: #3a3a3c; }
.kb-key.wide { width: 65px; font-size: 1em; }
.kb-key:active { filter: brightness(0.9); }

button {
  background: #393a41;
  color: #fff;
  font-weight: 600;
  font-size: 1.09em;
  border: none;
  border-radius: 7px;
  padding: 10px 16px;
  margin-bottom: 7px;
  cursor: pointer;
  box-shadow: 0 1px 1px #0002;
  transition: background 0.15s;
}
button:hover, button:focus { background: #44464f; }
button:active { background: #262626; }

.icon-btn {
  background: #252527;
  border: none;
  border-radius: 6px;
  width: 42px; height: 42px;
  font-size: 1.54em;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.16s;
  padding: 0;
}
.icon-btn:hover { background: #333345; }

#save-prompt {
  background: #1d1d27;
  border-radius: 8px;
  margin-top: 16px;
  padding: 13px;
  font-size: 0.98em;
  color: #f7d560;
}

.modal {
  display: none;
  position: fixed; z-index: 100;
  left: 0; top: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.5);
  justify-content: center; align-items: center;
}
.modal-content {
  background: #23242b;
  margin: 8vh auto;
  border-radius: 16px;
  padding: 32px 30px 22px 30px;
  width: 360px; max-width: 96vw;
  color: #fff;
  box-shadow: 0 8px 40px #000c;
  position: relative;
}
.close {
  position: absolute; right: 16px; top: 16px;
  color: #aaa;
  font-size: 1.8em;
  cursor: pointer;
}
.avatar-gallery {
  margin: 0 0 18px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}
.avatar-option {
  width: 52px; height: 52px; border-radius: 50%;
  border: 2.5px solid #444; background: #fff;
  cursor: pointer;
  transition: border 0.14s;
}
.avatar-option.selected { border-color: #b59f3b; }
#profile-modal-content {
  text-align: center;
}

.leaderboard-entry {
  margin-bottom: 17px;
  padding-bottom: 7px;
  border-bottom: 1px solid #35353d;
  display: flex;
  gap: 9px;
  align-items: flex-start;
}
.leaderboard-entry:last-child { border-bottom: none; }
.leaderboard-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: #fff; border: 2px solid #444;
}
.leaderboard-pattern {
  font-size: 1.23em;
  line-height: 1.06;
  letter-spacing: -1px;
  font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Segoe UI', sans-serif;
  margin: 2px 0 0 0;
  white-space: pre;
}

@media (max-width: 700px) {
  #app {
    width: 99vw;
    max-width: 99vw;
    padding: 14px 1vw 14px 1vw;
    margin-top: 12px;
  }
  .modal-content {
    width: 99vw;
    padding: 18px 7vw 14px 7vw;
    margin: 2vh auto;
    min-width: 0;
    max-width: 100vw;
  }
  .avatar-option { width: 38px; height: 38px; }
  #game-board {
    grid-template-rows: repeat(6, 38px);
    grid-template-columns: repeat(5, 38px);
    gap: 4px;
  }
  .tile {
    width: 38px; height: 38px;
    font-size: 1.15em;
  }
  .kb-key, .kb-key.wide {
    width: 27px !important; height: 40px !important; font-size: 1em !important;
  }
  .kb-key.wide { width: 42px !important; }
}
#layout {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  width: 100vw;
  min-height: 100vh;
  background: #121213;
}
#leaderboard-aside {
  min-width: 300px;
  max-width: 340px;
  background: #18181c;
  border-right: 2px solid #23242b;
  min-height: 100vh;
  padding: 32px 12px 20px 12px;
  box-sizing: border-box;
  box-shadow: 0 0 30px #0005;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  z-index: 20;
}
#leaderboard-aside-content {
  width: 100%;
}

#app {
  margin: 0 auto;
  padding: 32px 40px 24px 40px;
  background: #1a1a1b;
  border-radius: 16px;
  box-shadow: 0 6px 36px #000b;
  width: 480px;
  max-width: 98vw;
}

@media (max-width: 1100px) {
  #layout { flex-direction: column; }
  #leaderboard-aside {
    min-width: 0;
    max-width: 100vw;
    min-height: unset;
    border-right: none;
    border-bottom: 2px solid #23242b;
    flex-direction: row;
    width: 100vw;
    padding: 16px 2vw 10px 2vw;
    box-shadow: none;
  }
  #app {
    border-radius: 0 0 16px 16px;
  }
}
#toast-message {
  position: relative;
  margin: 0 auto 10px auto;
  max-width: 400px;
  background: #272728;
  color: #f9f9fa;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 1.05em;
  text-align: center;
  z-index: 40;
  box-shadow: 0 2px 8px #0006;
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
  user-select: none;
}
#toast-message[style*="display: block"] {
  opacity: 1;
  pointer-events: auto;
}
.leaderboard-streak {
  margin-left: 6px;
  font-size: 1.12em;
  color: #ffc600;
  vertical-align: middle;
  font-weight: bold;
  letter-spacing: 1px;
}

