body {
  font-family: system-ui, sans-serif;
  width: 502px;
  margin: 2rem auto;
  padding: 0 1rem;
}

* { box-sizing: content-box; }

.button {
  font-size: 0.9rem;
  text-decoration: none;
  padding: 3px 9px;
  border: 1px solid black;
  color: black;
  background: white;
  cursor: pointer;
  &:hover {
    background-color: black;
    color: white;
  }
}

#site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;

  #logo {
    text-decoration: none !important;

    h1 {
      margin: 0;
      color: black;
      letter-spacing: -3px;
      font-size: 2.5rem;
      -webkit-text-stroke: 1px black;
      paint-order: stroke fill;
      position: relative;

      &::after {
        content: 'qckchs';
        position: absolute;
        left: 2px;
        top: 2px;
        z-index: -1;
        background-color: white;
        background-clip: text;
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        -webkit-text-stroke: 1px black;
        paint-order: stroke fill;
      }

      &:hover {
        color: white;
        -webkit-text-stroke: 2px black;
        &::after {
          background-color: black;
          -webkit-text-fill-color: black;
        }
      }
    }
  }

  &.white-player #logo h1, &.spectator-player #logo h1 {
    color: white;
    -webkit-text-stroke: 2px black;
    &::after {
      background-color: black;
      -webkit-text-fill-color: black;
    }
    &:hover {
      color: black;
      &::after {
        background-color: white;
        -webkit-text-fill-color: transparent;
      }
    }
  }

  .header-link {
    font-size: 0.75rem;
  }
}

.profile-page {
  .form-field {
    margin-bottom: 1rem;

    label {
      display: block;
      font-weight: 600;
      margin-bottom: 0.25rem;
    }

    input[type="text"] {
      font-size: 0.9rem;
      padding: 0.25rem 0.5rem;
    }

    .name-input {
      display: flex;
      gap: 0.5rem;
      align-items: center;

      input { max-width: 50%; }
    }
  }

  .pk-display {
    font-family: monospace;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;

    input:disabled { color: black; }

    button {
      font-size: 0.75rem;
      padding: 0.15rem 0.4rem;
    }
  }

  .profile-stats {
    width: 500px;
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    margin: 2rem 0;
    > div {
      background: black;
      color: white;
      padding: 10px 20px;
      font-size: 1.2rem;
      text-align: center;
      display: flex;
      flex-direction: column;
      align-items: center;
      label {
        font-size: 0.9rem;
      }
      strong {
        font-size: 1.5rem;
      }
    }
  }

  .notice {
    background: black;
    color: white;
    border: 1px solid black;
    padding: 0.5rem 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
  }
}

.new-game-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  align-items: center;
  justify-content: start;
  background-color: white;
  background-image: repeating-linear-gradient(
    -45deg,
    #000 0px, #000 0.5px,
    transparent 0.5px, transparent 50%
  );
  background-size: 8px 8px;
  border: 1px solid black;
  text-align: center;
  font-size: 0.8rem;
  padding: 1.25rem 2rem;
  label { font-size: 0.75rem; background: white; padding: 0 0.25rem; }
  .buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
  }
}

.player-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.25rem;
  font-size: 0.9rem;

  .player-name {
    font-weight: 600;
  }

  .player-time {
    font-variant-numeric: tabular-nums;
    font-family: monospace;
  }
}

.game-area {
  position: relative;
}

.game-status {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  text-align: center;
  font-size: 0.8rem;
  padding: 2rem 3rem;
  background: rgba(244, 244, 244, 0.95);
  border: 1px solid black;
  color: #666;

  .dismiss-btn {
    position: absolute;
    top: 0.25rem;
    right: 0.5rem;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 0;
  }

  p {
    margin-top: 0;
    margin-bottom: 0.2rem;
  }
}

#board {
  width: 500px;
  height: 600px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(6, 1fr);
  border: 1px solid black;
  box-sizing: content-box;

  > div.sq {
    position: relative;
    display: grid;
    justify-items: center;
    align-items: center;
    background: #FFF;
    border: 1px solid black;
    width: 100px;
    height: 100px;
    box-sizing: border-box;
    overflow: hidden;
    &:nth-child(odd)::before {
      content: '';
      position: absolute;
      inset: -50%;
      width: 200%;
      height: 200%;
      background-color: white;
      background-image: repeating-linear-gradient(
        -45deg,
        #000 0px, #000 0.5px,
        transparent 0.5px, transparent 50%
      );
      background-size: 8px 8px;
      pointer-events: none;
    }
    &.dragging { opacity: 0.3; }
    > img {
      width: 80%;
      height: 80%;
      position: relative;
      z-index: 1;
    }
    &.valid-target::after {
      content: '';
      position: absolute;
      inset: 0;
      pointer-events: none;
      z-index: 2;
      background:
        linear-gradient(135deg, rgba(0,0,0,1) 8px, transparent 8px),
        linear-gradient(225deg, rgba(0,0,0,1) 8px, transparent 8px),
        linear-gradient(315deg, rgba(0,0,0,1) 8px, transparent 8px),
        linear-gradient(45deg, rgba(0,0,0,1) 8px, transparent 8px);
      background-position: top left, top right, bottom right, bottom left;
      background-size: 50% 50%;
      background-repeat: no-repeat;
    }
    &.hover-target::after {
      background:
        linear-gradient(135deg, rgba(0,0,0,1) 10px, transparent 10px),
        linear-gradient(225deg, rgba(0,0,0,1) 10px, transparent 10px),
        linear-gradient(315deg, rgba(0,0,0,1) 10px, transparent 10px),
        linear-gradient(45deg, rgba(0,0,0,1) 10px, transparent 10px);
      background-position: top left, top right, bottom right, bottom left;
      background-size: 50% 50%;
      background-repeat: no-repeat;
    }
  }
}

.drag-clone {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  display: grid;
  justify-items: center;
  align-items: center;
}

#lobby, .profile-games {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 1rem;
}

.mini-game {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}

.mini-bar {
  display: flex;
  justify-content: space-between;
  font-size: 0.6rem;
  padding: 0.1rem 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  max-width: 115px;
  line-height: 1.2;
  min-height: 0.9em;

  span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.mini-board {
  width: 115px;
  height: 138px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(6, 1fr);
  border: 0.5px solid black;
  box-sizing: content-box;

  > div.sq {
    position: relative;
    display: grid;
    justify-items: center;
    align-items: center;
    background: #FFF;
    border: 0.5px solid black;
    width: 23px;
    height: 23px;
    box-sizing: border-box;
    overflow: hidden;
    &:nth-child(odd)::before {
      content: '';
      position: absolute;
      inset: -50%;
      width: 200%;
      height: 200%;
      background-color: white;
      background-image: repeating-linear-gradient(
        -45deg,
        #BBB 0px, #BBB 0.5px,
        transparent 0.5px, transparent 50%
      );
      background-size: 3px 3px;
      pointer-events: none;
    }
    > img {
      width: 80%;
      height: 80%;
      position: relative;
      z-index: 1;
    }
  }
}
