/* #region [ Fonts ] */
/**/
@font-face {
    font-family: 'AlphaProta';
    src: url('./assets/fonts/AlphaProta-G33Vm.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'BittypixMonospace';
    src: url('./assets/fonts/BittypixMonospace-3gAG.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/**/
/* #endregion */

/* #region [ Root & Core ] */
/**/
:root {
    --primary-color: #ffffff;
    --secondary-color: #b3b3b3;
    --tertiary-color: #d6d6d6;

    --black: #000000;
    --black-05: #00000020;
    --black-20: #00000040;
    --black-60: #000000bd;

    --grey: #6e6e6e;
    --grey-slate-20: #ffffff33;

    --font-heading: 'AlphaProta', Arial, sans-serif;
    --font-mono: 'BittypixMonospace', 'Courier New', monospace;
    --primary-font-size: 16px;
    --secondary-font-size: 12px;

    --primary-radius: 8px;
    --secondary-radius: 4px;
    --tertiary-radius: 10px;
    --smooth-radius: 1rem;

    --rarity-0: #ffffff;
    --rarity-1: #1eff00;
    --rarity-2: #0099ff;
    --rarity-3: #9d00ff;
    --rarity-4: #ff9500;

    --center: translate(-50%, -50%);
}

* {
    display: flex;
    justify-content: center;
    align-content: center;
    flex-wrap: wrap;
    font-family: var(--font-mono);
    transition: all 0.25s ease-in-out;
}

body {
    flex-direction: column;
    font-family: Arial, sans-serif;
    padding: 20px;
    max-width: 900px;
    margin: auto;
    background: var(--black);
    overflow: hidden;
}

p {
    color: var(--tertiary-color);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    user-select: none;
}

h1 {
    position: absolute;
    bottom: 0px;
    right: 10px;
    font-size: 5rem;
    font-weight: bold;
    color: var(--grey);
}

button {
    margin: 10px;
    padding: 12px 24px;
    font-size: var(--primary-font-size);
    font-family: var(--font-mono);
    color: var(--primary-color);
    background-image: url('./assets/img/bg2.jpg');
    border-radius: var(--tertiary-radius);
    cursor: pointer;
}

button:hover {
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.25);

}

toggle {
    position: relative;
    width: 3rem;
    height: 1.5rem;
    background: var(--grey-slate-20);
    border: 2px solid var(--primary-color);
    border-radius: var(--smooth-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

toggle::before {
    content: '';
    position: absolute;
    top: 0.125rem;
    left: 0.125rem;
    width: 1rem;
    height: 1rem;
    background: var(--primary-color);
    border-radius: 50%;
    transition: all 0.3s ease;
}

toggle[checked] {
    background: var(--primary-color);
}

toggle[checked]::before {
    background: var(--black);
    transform: translateX(1.5rem);
}

toggle:hover {
    box-shadow: 0 0 0.5rem rgba(255, 255, 255, 0.3);
}

/**/
/* #endregion */

/* #region [ Core ] */
/**/
.container {
    flex-direction: column;
}

.row {
    flex-direction: row !important;
}

.hidden {
    display: none;
}

/**/
/* #endregion */

/* #region [ User & Room Info ] */
/**/
.user_info {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: var(--center);
    background-image: url('./assets/img/bg3.jpg');
    background-size: 75%;
    padding: 15px;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    margin-bottom: 20px;
}

.user_info>* {
    color: var(--primary-color);
}

#roomId {
    margin: 1rem;
}

#gameRoomId {
    display: none;
}

/**/
/* #endregion */

/* #region [ Game Interface ] */
/**/
.game_container {
    padding: 1rem;
}

.room_controls,
.game_container {
    background: var(--tertiary-color);
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background-image: url('./assets/img/bg.png');
}

.room_controls {
    text-align: center;
    padding: 10rem;
}

.room_controls h2 {
    color: var(--secondary-color);
    margin-bottom: 20px;
    font-family: var(--font-heading);
}

.game_header {
    background: var(--tertiary-color);
    padding: 0.25rem;
    border-radius: var(--primary-radius);
    border: 1px solid #dee2e6;
}

.game_header h3 {
    margin: 0 0 10px 0;
    color: #495057;
}

#gameCanvas {
    border: 3px solid var(--secondary-color);
    border-radius: 8px;
    background-image: url('./assets/img/bg4.jpg');
    background-size: 25%;
    margin: 15px auto;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/**/
/* #endregion */

/* #region [ Upgrade ] */
/**/
.upgrade_container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: var(--center);
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 30px;
    z-index: 1000;
    backdrop-filter: blur(10px);
    gap: 20px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    max-width: 800px;
}

.upgrade_waiting {
    color: var(--primary-color);
    font-family: var(--font-heading);
    font-size: 18px;
    text-align: center;
    padding: 20px;
}

.upgrade_card {
    width: 200px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.upgrade_card:hover {
    transform: translateY(-3px);
    background: var(--grey-slate-20);
    border-color: var(--primary-color);
}

.upgrade_card[data-rarity="0"] {
    border-color: var(--rarity-0);
}

.upgrade_card[data-rarity="1"] {
    border-color: var(--rarity-1);
}

.upgrade_card[data-rarity="2"] {
    border-color: var(--rarity-2);
}

.upgrade_card[data-rarity="3"] {
    border-color: var(--rarity-3);
}

.upgrade_card[data-rarity="4"] {
    border-color: var(--rarity-4);
}

.upgrade_name {
    font-family: var(--font-heading);
    font-size: var(--primary-font-size);
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.upgrade_subtitle {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--secondary-color);
    line-height: 1.3;
}

/**/
/* #endregion */

/* #region [ HUD ] */
/**/
#hud {
    position: fixed;
    flex-wrap: nowrap;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    backdrop-filter: blur(5px);
    padding: 10px;
    z-index: 50;
}

/* Inventory Section - 20% */
#inventory {
    flex: 2;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--grey-slate-20);
    border-top-left-radius: var(--primary-radius);
    justify-content: space-between;
    align-items: center;
    flex-direction: row;
}

/* .inventory_item {

} */

#invAmmoReserves {
    width: 100px;
    height: 100%
}

/* Stats Section - 40% */
#playerStats {
    flex: 4;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--grey-slate-20);
    border-bottom-right-radius: var(--primary-radius);
    border-bottom-left-radius: var(--primary-radius);
    padding: 0.5rem;
    flex-wrap: nowrap;
    gap: 0;
}

.stat,
.divider {
    min-width: 0;
    justify-content: center;
    align-items: center;
}

.stat {
    flex: 1 1 0;
    white-space: nowrap;
    flex-direction: row;
    align-items: center;
    gap: 5px;
    justify-content: center;
    overflow: hidden;
    background: var(--black-60);
    border-radius: var(--primary-radius);
    border: 1px solid var(--secondary-color);
}

.stat img {
    width: 35px;
    height: 35px;
}

.stat span {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--primary-color);
    white-space: nowrap;
}

.stat span:first-child {
    color: var(--secondary-color);
    font-weight: bold;
}

.stat span:last-child {
    color: var(--primary-color);
    font-weight: normal;
}

/* Vitals Section - 40% */
#vitals {
    flex: 4;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--grey-slate-20);
    border-top-right-radius: var(--primary-radius);
    padding-left: 0rem;
    padding-right: 0.5rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
}

#healthRow,
#staminaRow {
    width: 100%;
}

#healthBar,
#staminaBar {
    flex: 1;
    justify-content: flex-start;
    width: 100%;
    height: 18px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--primary-color);
    border-radius: 9px;
    overflow: hidden;
    position: relative;
    flex-direction: row;
}

#healthFill,
#staminaFill {
    height: 100%;
    width: 100%;
    border-radius: inherit;
    transition: width 0.3s ease;
    flex-shrink: 0;
}

#healthFill {
    background: linear-gradient(90deg, #ff4444, #ff6666);
}

#staminaFill {
    background: linear-gradient(90deg, #44ff47, #82e449);
}

#crosshair {
    position: fixed;
    width: 20px;
    height: 20px;
    pointer-events: none;
    z-index: 9999;
    transform: var(--center);
    transition: none;
}

#crosshair::before,
#crosshair::after {
    content: '';
    position: absolute;
    background-color: var(--primary-color);
}

#crosshair::before {
    left: 50%;
    top: 2px;
    bottom: 2px;
    width: 2px;
    transform: translateX(-50%);
}

#crosshair::after {
    top: 50%;
    left: 2px;
    right: 2px;
    height: 2px;
    transform: translateY(-50%);
}

/**/
/* #endregion */

/* #region [ Visuals ] */
/**/
#saltpeterTitle {
    z-index: -1;
}

#fg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url(./assets/img/noise.gif) center;
    background-size: 50%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.075;
}

.hacker {
    position: absolute;
    top: 0;
    left: 0;
    height: 100px;
    width: 50%;
    z-index: -1;
}

.hacker * {
    user-select: none;
    pointer-events: none;
}

.hacker_bars {
    left: 50%;
}

.hacker_console {
    color: var(--primary-color);
    max-width: 40rem;
    margin: auto 1rem;
    overflow-y: clip;
}

/**/
/* #endregion */

/* #region [ Lobby ] */
/**/
.lobby_container {
    background: var(--tertiary-color);
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background-image: url('./assets/img/bg.png');
    padding: 1rem;
    min-height: 400px;
}

.lobby_players {
    margin: 20px 0;
    flex-direction: column;
}

.lobby_players h4 {
    color: var(--secondary-color);
    margin-bottom: 15px;
    font-family: var(--font-heading);
}

.players_list {
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.lobby_player {
    flex-direction: row;
    align-items: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    gap: 15px;
}

.player_color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--secondary-color);
    flex-shrink: 0;
}

.player_name {
    flex: 1;
    color: var(--secondary-color);
    font-family: var(--font-mono);
    font-weight: bold;
}

.player_controls {
    flex-direction: row;
    gap: 5px;
}

.player_controls button {
    padding: 5px 10px;
    font-size: var(--secondary-font-size);
    margin: 0;
}

.start_game_btn {
    margin-top: 20px;
    padding: 15px 30px;
    font-size: 18px;
    font-family: var(--font-heading);
    background-image: url('./assets/img/bg2.jpg');
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    cursor: pointer;
    align-self: center;
}

.start_game_btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#joinButtons>* {
    flex: 1;
}

.game_options {
    margin: 1.25rem 0;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid var(--primary-color);
    border-radius: var(--primary-radius);
    backdrop-filter: blur(5px);
    flex-direction: column;
    gap: 0.5rem;
}

.game_options span {
    user-select: none;
}

.game_options_row {
    flex-direction: row;
    gap: 1rem;
}

.game_option {
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    gap: 1rem;
}

.game_option:last-child {
    border-bottom: none;
}

.game_option span {
    color: var(--primary-color);
    font-family: var(--font-mono);
    font-weight: bold;
}

.game_option_input {
    width: 2rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--primary-color);
    border-radius: var(--primary-radius);
    color: var(--primary-color);
    font-family: var(--font-mono);
    font-size: var(--secondary-font-size);
    text-align: center;
    flex-shrink: 0;
}

.game_option_input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}

.game_option_input:hover {
    background: rgba(255, 255, 255, 0.15);
}


/**/
/* #endregion */

/* #region [ Modal ] */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--black-20);
    backdrop-filter: blur(8px);
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

#modalContent {
    background: var(--black-60);
    border: 1px solid var(--secondary-color);
    border-radius: var(--primary-radius);
    padding: 2rem 4rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    align-items: center;
    flex-direction: column;
    min-width: 600px;
}

#modalText {
    color: var(--secondary-color);
    margin: 1rem;
    font-size: larger;
}

.modal_input {
    width: 100%;
    padding: 10px 12px;
    margin: 16px 0 8px 0;
    border-radius: var(--primary-radius);
    border: 1px solid var(--primary-color);
    background: #222;
    color: var(--primary-color);
    font-size: var(--primary-font-size);
    font-family: var(--font-mono);
}

.modalButtons {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.modal_btn {
    padding: 8px 18px;
    border-radius: var(--primary-radius);
    border: none;
    background: var(--primary-color);
    color: #000;
    cursor: pointer;
    font-weight: bold;
}

.modal_btn.danger {
    background: #a33;
    color: #fff;
}

.modal_error {
    color: #ff4444;
    font-size: 13px;
    margin-top: 8px;
    min-height: 18px;
}

/* #endregion */

/* #region [ Dividers] */
.divider {
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-position: center;
}

.stats_divider {
    flex: 0.5 1 0;
}

.vitals_divider {
    flex: 0.1 1 0;
    background-image: url('./assets/img/icon/elements/wireconnector_60px_03.png');

}

.stamina_divider {
    flex: 0.25 1 0;
    background-image: url('./assets/img/icon/elements/wireconnector_120px.png');
}

.divider.top,
.divider.middle,
.divider.bottom {
    height: 16px;
    align-self: center;
}

#playerStats>div.divider:nth-child(2) {
    /* 1st divider */
    background-image: url('./assets/img/icon/elements/wireconnector_60px_01.png');
    transform: translateY(20%);
}

#playerStats>div.divider:nth-child(4) {
    /* 2nd divider */
    background-image: url('./assets/img/icon/elements/wireconnector_60px_02.png');
    transform: translateY(-12%);
}

#playerStats>div.divider:nth-child(6) {
    /* 3rd divider */
    background-image: url('./assets/img/icon/elements/wireconnector_60px_05.png');
    transform: translateY(5%);
}

#playerStats>div.divider:nth-child(8) {
    /* 4th divider */
    background-image: url('./assets/img/icon/elements/wireconnector_60px_04.png');
    transform: translateY(-35%);
}

#playerStats>div.divider:nth-child(10) {
    /* 5th divider */
    background-image: url('./assets/img/icon/elements/wireconnector_60px_00.png');
}

/* #endregion */

/* #region [ Chat ] */
/**/
.chat_container {
    position: fixed;
    top: 20px;
    right: 20px;
    left: auto;
    bottom: auto;
    width: 350px;
    height: 400px;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    flex-direction: column;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.chat_messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    gap: 8px;
    align-content: flex-end;
    justify-content: flex-start;
    font-family: var(--font-mono);
    font-size: var(--secondary-font-size);
}

.chat_message {
    justify-content: flex-start;
    width: 100%;
    word-wrap: break-word;
    margin: 2px 0;
    padding: 4px 0;
}

.chat_message.own {
    color: var(--primary-color);
}

.chat_message.other {
    color: var(--secondary-color);
}

.chat_message .sender {
    font-weight: bold;
    margin-right: 8px;
}

.chat_message .content {
    color: var(--tertiary-color);
}

.chat_input_row {
    padding: 10px;
    border-top: 1px solid var(--primary-color);
    flex-direction: row;
    gap: 8px;
}

.chat_input {
    flex: 1;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    color: var(--primary-color);
    font-family: var(--font-mono);
    font-size: var(--secondary-font-size);
}

.chat_input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}

.chat_send_btn {
    flex: 1;
    padding: 8px 16px;
    background: var(--primary-color);
    color: var(--black);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: var(--secondary-font-size);
    font-weight: bold;
    margin: 0;
}

.chat_send_btn:hover {
    background: var(--secondary-color);
}

.chat_send_btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/**/
/* [ Chat Scrollbar ] */
.chat_messages::-webkit-scrollbar {
    width: 6px;
}

.chat_messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.chat_messages::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.chat_messages::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/**/
/* #endregion */

/* #region [ Leaderboard ] */
/**/
.leaderboard_container {
    position: fixed;
    top: 20px;
    right: auto;
    left: 20px;
    bottom: auto;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    z-index: 99;
    backdrop-filter: blur(5px);
    font-family: var(--font-mono);
}

.leaderboard_container * {
    flex: 1;
}

.leaderboard_table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--secondary-font-size);
    flex-direction: column;
}

.leaderboard_header th {
    padding: 12px 8px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary-color);
    border-bottom: 1px solid var(--primary-color);
    text-align: left;
    font-weight: bold;
    font-family: var(--font-mono);
}

#leaderboardBody {
    flex-direction: column;
    flex-wrap: nowrap;
}

.leaderboard_row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard_row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.leaderboard_row.current-player {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary-color);
    font-weight: bold;
}

.leaderboard_row td {
    padding: 8px;
    color: var(--secondary-color);
    text-align: left;
    font-family: var(--font-mono);
}

.leaderboard_row.current-player td {
    color: var(--primary-color);
}

.player_name {
    font-weight: bold;
    min-width: 80px;
}

.round_wins {
    color: var(--tertiary-color);
    font-weight: bold;
    text-align: center;
}

.kills,
.deaths {
    text-align: center;
    font-family: var(--font-mono);
}

/**/
/* #endregion */