\documentclass[a4paper]{article}
\usepackage{fancyhdr}
\usepackage{geometry}
\usepackage{fontspec}
\usepackage{import}
\usepackage[table,xcdraw]{xcolor}
\usepackage[parfill]{parskip}
\usepackage{enumitem}
\usepackage{tabularx}
\usepackage{titlesec}
\usepackage{listofitems}
\usepackage{nicematrix}
\usepackage{tikz}
\usepackage{stix}
\usepackage{amsmath}
\usetikzlibrary{shapes,shadows,calc}
\usetikzlibrary{positioning,calc}

\pagestyle{fancy}
\fancyhf{}
\fancyheadoffset{0pt}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyhead[R]{\thepage}
\fancypagestyle{plain}{%
    \fancyhf{}%
    \fancyhead[R]{\thepage}%
}

\definecolor{titlecolor}{HTML}{ffb030}
\definecolor{diecolor}{HTML}{1d4596}
\definecolor{tablecolor1}{HTML}{f0dda5}
\definecolor{tablecolor2}{HTML}{f6edd0}

\definecolor{tablecolor3}{HTML}{c3dfcb}
\definecolor{tablecolor4}{HTML}{e2efe6}


\geometry{
    a4paper,
    left=45pt,
    right=45pt,
    top=20pt,
    bottom=20pt,
    headsep=-10pt
}

\setcounter{secnumdepth}{0}

\setmainfont[BoldFont=Cala W01 Bold,ItalicFont=Cala W01 Italic]{Cala W01 Regular}
\newfontfamily\titlefont{Fontdiner Swanky}
\newfontfamily\subtitlefont{Futura}
\def\arraystretch{1.2}

\newcommand\SecTitle[1]{%
\begin{tikzpicture}
    \clip (0,0.75)--(15,0.75)--(14,-0.75)--(0,-0.75)--cycle;
    \path [draw=titlecolor,line width=1.5cm](0,0)--(20,0);
    \node [color=black,align=left,anchor=west] at (1,0) {\titlefont\huge#1};

\end{tikzpicture}

}

\titleformat{name=\section}[block]
  {}
  {}
  {0pt}
  {\SecTitle}
\titlespacing*{\section}{-50pt}{0pt}{0pt}

\titleformat{name=\subsection}[block]
  {\LARGE}
  {}
  {0pt}
  {\subtitlefont\MakeUppercase}[\hrule]
\titlespacing*{\subsection}{-10pt}{30pt}{5pt}

\titleformat{name=\subsubsection}[block]
  {\vspace*{10pt}\large}
  {}
  {0pt}
  {\subtitlefont\MakeUppercase}
\titlespacing*{\subsubsection}{0pt}{0pt}{0pt}

\newcommand{\dice}{$\color{diecolor}\blacksquare$}

\newcommand{\SPECIAL}[7]{%
\begin{center}
\vspace*{10pt}
\subtitlefont\large
\begin{tabular}{*{7}{w{c}{0.777cm}}}
  \rowcolor[HTML]{000000}%
  \color{white}S & \color{white}P & \color{white}E & \color{white}C & \color{white}I & \color{white}A & \color{white}L \\
  \rowcolor{tablecolor3}
  #1 & \cellcolor{tablecolor4}#2 & #3 & \cellcolor{tablecolor4}#4 & #5 & \cellcolor{tablecolor4}#6 & #7 \\
\end{tabular}%
\end{center}%
}

\newenvironment{skills}{%
  \begin{center}
  \vspace*{10pt}
  \subtitlefont
  \rowcolors{1}{tablecolor3}{tablecolor4}
  \begin{tabular}{*{2}{w{l}{2.755cm}w{c}{0.6cm}}}
  \rowcolor{black}
  \multicolumn{4}{c}{\color{white}\small{}SKILLS} \\ \hline
  }{%
  \end{tabular}
  \end{center}
}

\newcommand{\derived}[6]{%
\begin{center}
\vspace*{10pt}
\subtitlefont
\begin{tabular}{*{3}{w{c}{2.378cm}}}
  \rowcolor[HTML]{000000}%
  \color{white}\small{}HP & \color{white}\small{}INITIATIVE & \color{white}\small{}DEFENSE \\
  \rowcolor{tablecolor3}
  #1 & \cellcolor{tablecolor4}#2 & #3\\
\end{tabular}\vspace*{10pt}
\begin{tabular}{*{3}{w{c}{2.378cm}}}
  \rowcolor[HTML]{000000}%
  \color{white}\small{}CARRY WEIGHT & \color{white}\small{}MELEE BONUS & \color{white}\small{}LUCK POINTS \\
  \rowcolor{tablecolor3}
  #4 & \cellcolor{tablecolor4}#5 & #6\\
\end{tabular}%
\end{center}%
}

\newcommand{\damager}[4]{%
\readlist*\listone{#1}%
\readlist*\listtwo{#2}%
\readlist*\listthree{#3}%
\readlist*\listfour{#4}%
\begin{center}
\vspace*{10pt}
\subtitlefont
\begin{tabular}{w{l}{0.85cm}*{4}{w{c}{1.36cm}}}
  \rowcolor[HTML]{000000}%
  \multicolumn{5}{c}{\color{white}DAMAGE RESISTANCES} \\
  \rowcolor[HTML]{000000}%
  & \color{white}\small{}PHYS. & \color{white}\small{}ENERGY & \color{white}\small{}RAD. & \color{white}\small{}POISON \\
  \rowcolor{tablecolor3}
  \cellcolor{tablecolor4}Head & \listone[1] & \cellcolor{tablecolor4}\listtwo[1] & \listthree[1] & \cellcolor{tablecolor4}\listfour[1]\\
  \rowcolor{tablecolor3}
  \cellcolor{tablecolor4}Torso & \listone[2] & \cellcolor{tablecolor4}\listtwo[2] & \listthree[2] & \cellcolor{tablecolor4}\listfour[2]\\
  \rowcolor{tablecolor3}
  \cellcolor{tablecolor4}Arms & \listone[3] & \cellcolor{tablecolor4}\listtwo[3] & \listthree[3] & \cellcolor{tablecolor4}\listfour[3]\\
  \rowcolor{tablecolor3}
  \cellcolor{tablecolor4}Legs & \listone[4] & \cellcolor{tablecolor4}\listtwo[4] & \listthree[4] & \cellcolor{tablecolor4}\listfour[4]\\
\end{tabular}
\end{center}%
}

\newcommand{\damagers}[4]{%
\begin{center}
\vspace*{10pt}
\subtitlefont
\begin{tabular}{*{4}{w{c}{1.678cm}}}
  \rowcolor[HTML]{000000}%
  \multicolumn{4}{c}{\color{white}DAMAGE RESISTANCES} \\
  \rowcolor[HTML]{000000}%
  \color{white}\small{}PHYS. & \color{white}\small{}ENERGY & \color{white}\small{}RAD. & \color{white}\small{}POISON \\
  \rowcolor{tablecolor3}
  #1 & \cellcolor{tablecolor4}#2 & #3 & \cellcolor{tablecolor4}#4\\
  \rowcolor{tablecolor3}
\end{tabular}
\end{center}%
}

\newenvironment{attacks}{%
  \begin{center}
  \vspace*{10pt}
  \subtitlefont
  \rowcolors{1}{tablecolor3}{tablecolor4}
  \begin{tabular}{w{c}{0.1cm}p{7.455cm}}
  \rowcolor{black}
  \multicolumn{2}{c}{\color{white}ATTACKS} \\
  }{%
  \end{tabular}
  \end{center}
}

\newcommand{\attack}[4]{$\mdblksquare$ & \small\textbf{#1: #2} (TN #3), #4\\}

\newenvironment{abilities}{%
  \begin{center}
  \vspace*{10pt}
  \subtitlefont
  \rowcolors{1}{tablecolor3}{tablecolor4}
  \begin{tabular}{w{c}{0.1cm}p{7.455cm}}
  \rowcolor{black}
  \multicolumn{2}{c}{\color{white}ABILITIES} \\
  }{%
  \end{tabular}
  \end{center}
}

\newcommand{\ability}[2]{$\mdblksquare$ & \small\textbf{\MakeUppercase{#1}:} #2\\}

\newcommand{\inventory}[1]{%
\begin{center}
\vspace*{10pt}
\subtitlefont
\begin{tabular}{p{7.975cm}}
  \rowcolor[HTML]{000000}%
  \multicolumn{1}{c}{\color{white}INVENTORY} \\
  \rowcolor{tablecolor3}\small{}#1
\end{tabular}
\end{center}%
}

\begin{document}
\setcounter{page}{1}
\input{parts/basic.tex}
\newpage
%\input{parts/wasteland_survival.tex}
%\newpage
\input{parts/combat.tex}
\newpage
\setcounter{page}{1}
\input{parts/character_creation.tex}
\newpage
\setcounter{page}{1}
\input{parts/npcs.tex}

\end{document}