:root {
  --green: #6aaa64;
  --yellow: #c9b458;
  --gray: #787c7e;
  --light-gray: #d3d6da;
  --text: #1f2328;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button {
  color: inherit;
  font: inherit;
}

header {
  height: 64px;
  padding: 0 18px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--light-gray);
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  letter-spacing: 3px;
}

nav {
  justify-self: end;
  display: flex;
  gap: 4px;
}

nav button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
}

main {
  width: min(100% - 24px, 520px);
  margin: auto;
  padding: 24px 0;
}

.subtitle {
  margin: 0 0 20px;
  color: #6b6f75;
  font-size: 14px;
  text-align: center;
}

.board {
  width: min(100%, 330px);
  margin: auto;
  display: grid;
  gap: 6px;
}

.row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.tile {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid var(--light-gray);
  font-size: 34px;
  font-weight: bold;
}

.tile.filled {
  border-color: #878a8c;
}

.tile.correct,
.tile.present,
.tile.absent {
  color: white;
  border-color: transparent;
}

.correct { background: var(--green); }
.present { background: var(--yellow); }
.absent { background: var(--gray); }

.keyboard {
  margin-top: 28px;
  display: grid;
  gap: 8px;
}

.key-row {
  display: flex;
  gap: 6px;
}

.key-row.middle {
  padding: 0 5%;
}

.keyboard button {
  height: 54px;
  min-width: 0;
  padding: 0;
  flex: 1;
  border: 0;
  border-radius: 5px;
  background: var(--light-gray);
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
}

.keyboard button:active {
  transform: scale(0.96);
}

.keyboard button.correct { color: white; background: var(--green); }
.keyboard button.present { color: white; background: var(--yellow); }
.keyboard button.absent { color: white; background: var(--gray); }

.keyboard button.wide {
  flex: 1.5;
  font-size: 11px;
}

dialog {
  width: min(90vw, 400px);
  padding: 28px;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 16px 50px #0004;
}

dialog::backdrop {
  background: #0008;
}

dialog h2,
dialog h3 {
  margin-top: 0;
}

dialog h3 {
  margin-top: 24px;
  font-size: 15px;
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  font-size: 26px;
  cursor: pointer;
}

#account-form {
  display: grid;
  gap: 14px;
}

#account-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: bold;
}

#account-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--light-gray);
  border-radius: 5px;
  font-size: 16px;
}

.primary {
  padding: 11px 16px;
  border: 0;
  border-radius: 5px;
  color: white;
  background: var(--green);
  font-weight: bold;
  cursor: pointer;
}

.auth-switch {
  display: flex;
  justify-content: center;
  gap: 14px;
}

.auth-switch button {
  border: 0;
  background: transparent;
  text-decoration: underline;
  cursor: pointer;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}

.stat-grid p {
  margin: 0;
}

.stat-grid strong,
.stat-grid span {
  display: block;
}

.stat-grid strong {
  font-size: 26px;
}

.stat-grid span {
  color: #6b6f75;
  font-size: 11px;
}

@media (max-width: 500px) {
  header {
    height: 56px;
    padding: 0 8px;
  }

  h1 {
    font-size: 23px;
    letter-spacing: 2px;
  }

  nav button {
    width: 31px;
  }

  .board {
    width: min(78vw, 315px);
  }

  .keyboard {
    gap: 6px;
  }

  .key-row {
    gap: 4px;
  }

  .keyboard button {
    height: 52px;
    font-size: 12px;
  }
}

@media (max-height: 720px) {
  main {
    padding-top: 14px;
  }

  .subtitle {
    margin-bottom: 12px;
  }

  .board {
    width: min(68vw, 280px);
  }

  .keyboard {
    margin-top: 16px;
  }

  .keyboard button {
    height: 46px;
  }
}
