So, the issue of using rolls only once also extends to using them as links - the triple brackets break if there's an already used roll inside them. While it's possible to use rolls to change the color in inline CSS with some trickery, here it isn't an option. However, I remembered I had already written something for this exact problem, and I sat down and adjusted it to default template (it used a template from a different sheet originally), as well as making some improvements. Save these two abilities, with the names provided above the macro:
chaos-bolt
&{template:default} {{name=Chaos Bolt [ ](#" hidden null=)
}} {{[Attack](#" hidden)=
}} {{[1](#" hidden)=Attack roll [ ](#" hidden null=)
}} {{[[[ {[[?{advantage|none,@{d20}|advantage,{@{d20},@{d20}}kh1|disadvantage,{@{d20},@{d20}}kl1}+@{spell_attack_bonus}]],0}>[[20+@{spell_attack_bonus}]] ]]](#" hidden)=[Critical hit!!](!/
%{@{character_name}|chaos-bolt-damage})[ ](#" hidden null=)
}} [[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]] {{[0](#" hidden)=[ ](#" hidden null=)
}} {{[0]=[ ](#" hidden null=)
}} {{[1]=[[1+1+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Acid damage, [the spell bounces to another target!](`%{@{character_name}|Chaos-Bolt})[ ](#" hidden null=)
}} {{[2]=[[1+2+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]]Cold or Acid damage[ ](#" hidden null=)
}} {{[3]=[[2+2+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Cold damage, [the spell bounces to another target!](`%{@{character_name}|Chaos-Bolt})[ ](#" hidden null=)
}} {{[4]=[[1+3+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Acid or Fire damage[ ](#" hidden null=)
}} {{[5]=[[1+4+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Acid or Force damage[ ](#" hidden null=)
}} {{[6]=[[2+3+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Cold or Fire damage[ ](#" hidden null=)
}} {{[7]=[[3+3+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Fire damage, [the spell bounces to another target!](`%{@{character_name}|Chaos-Bolt})[ ](#" hidden null=)
}} {{[8]=[[2+4+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Cold or Force damage[ ](#" hidden null=)
}} {{[9]=[[1+5+((?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Acid or Lightning damage[ ](#" hidden null=)
}} {{[10]=[[3+4+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Fire or Force damage[ ](#" hidden null=)
}} {{[11]=[[2+5+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Cold or Lightning damage[ ](#" hidden null=)
}} {{[12]=[[1+6+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Acid or Poison damage[ ](#" hidden null=)
}} {{[13]=[[4+4+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Force damage, [the spell bounces to another target!](`%{@{character_name}|Chaos-Bolt})[ ](#" hidden null=)
}} {{[14]=[[3+5+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Fire or Lightning damage[ ](#" hidden null=)
}} {{[15]=[[2+6+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Cold or Poison damage[ ](#" hidden null=)
}} {{[16]=[[1+7+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Acid or Psychic damage[ ](#" hidden null=)
}} {{[17]=[[4+5+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Force or Lightning damage[ ](#" hidden null=)
}} {{[18]=[[3+6+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Fire or Poison damage[ ](#" hidden null=)
}} {{[19]=[[2+7+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Cold or Psychic damage[ ](#" hidden null=)
}} {{[20]=[[1+8+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Acid or Thunder damage[ ](#" hidden null=)
}} {{[21]=[[5+5+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Lightning damage, [the spell bounces to another target!](`%{@{character_name}|Chaos-Bolt})[ ](#" hidden null=)
}} {{[22]=[[4+6+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Force or Poison damage[ ](#" hidden null=)
}} {{[23]=[[3+7+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Fire or Psychic damage[ ](#" hidden null=)
}} {{[24]=[[2+8+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Cold or Acid damage[ ](#" hidden null=)
}} {{[25]=[[5+6+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Lightning or Poison damage[ ](#" hidden null=)
}} {{[26]=[[4+7+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Force or Psychic damage[ ](#" hidden null=)
}} {{[27]=[[3+8+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Fire or Thunder damage[ ](#" hidden null=)
}} {{[28]=[[6+6+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Poison damage, [the spell bounces to another target!](`%{@{character_name}|Chaos-Bolt})[ ](#" hidden null=)
}} {{[29]=[[5+7+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Lightning or Psychic damage[ ](#" hidden null=)
}} {{[30]=[[4+8+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Force or Thunder damage[ ](#" hidden null=)
}} {{[31]=[[6+7+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Poison or Psychic damage[ ](#" hidden null=)
}} {{[32]=[[5+8+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Lightning or Thunder damage[ ](#" hidden null=)
}} {{[33]=[[7+7+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Psychic damage, [the spell bounces to another target!](`%{@{character_name}|Chaos-Bolt})[ ](#" hidden null=)
}} {{[34]=[[6+8+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Poison or Thunder damage[ ](#" hidden null=)
}} {{[35]=[[7+8+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Psychic or Thunder damage[ ](#" hidden null=)
}} {{[36]=[[8+8+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Thunder damage, [the spell bounces to another target!](`%{@{character_name}|Chaos-Bolt})[ ](#" hidden null=)
}} {{[cleaner](#)}}{{[[[{1,2,4,5,7,9,11,12,14,16,18,20,22,23,25,27,29,31,33,35,37,38,40,42,44,46,48,50,51,53,55,57,59,60,62,64}<[[1d64]] -1]]]=[ ](#)
}} {{[0](#" hidden)= [ ](#" hidden null=)
}} {{[Attack](#" hidden)=$[[0]] [ ](#" hidden null=)
}}
chaos-bolt-damage
&{template:default} {{name=Chaos Bolt critical damage [ ](#" hidden null=)
}} [[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]][[0]] {{[0]=[ ](#" hidden null=)
}} {{[1]=[[1+1+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Acid damage, [the spell bounces to another target!](`%{@{character_name}|Chaos-Bolt})[ ](#" hidden null=)
}} {{[2]=[[1+2+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]]Cold or Acid damage[ ](#" hidden null=)
}} {{[3]=[[2+2+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Cold damage, [the spell bounces to another target!](`%{@{character_name}|Chaos-Bolt})[ ](#" hidden null=)
}} {{[4]=[[1+3+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Acid or Fire damage[ ](#" hidden null=)
}} {{[5]=[[1+4+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Acid or Force damage[ ](#" hidden null=)
}} {{[6]=[[2+3+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Cold or Fire damage[ ](#" hidden null=)
}} {{[7]=[[3+3+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Fire damage, [the spell bounces to another target!](`%{@{character_name}|Chaos-Bolt})[ ](#" hidden null=)
}} {{[8]=[[2+4+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Cold or Force damage[ ](#" hidden null=)
}} {{[9]=[[1+5+((?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Acid or Lightning damage[ ](#" hidden null=)
}} {{[10]=[[3+4+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Fire or Force damage[ ](#" hidden null=)
}} {{[11]=[[2+5+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Cold or Lightning damage[ ](#" hidden null=)
}} {{[12]=[[1+6+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Acid or Poison damage[ ](#" hidden null=)
}} {{[13]=[[4+4+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Force damage, [the spell bounces to another target!](`%{@{character_name}|Chaos-Bolt})[ ](#" hidden null=)
}} {{[14]=[[3+5+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Fire or Lightning damage[ ](#" hidden null=)
}} {{[15]=[[2+6+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Cold or Poison damage[ ](#" hidden null=)
}} {{[16]=[[1+7+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Acid or Psychic damage[ ](#" hidden null=)
}} {{[17]=[[4+5+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Force or Lightning damage[ ](#" hidden null=)
}} {{[18]=[[3+6+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Fire or Poison damage[ ](#" hidden null=)
}} {{[19]=[[2+7+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Cold or Psychic damage[ ](#" hidden null=)
}} {{[20]=[[1+8+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Acid or Thunder damage[ ](#" hidden null=)
}} {{[21]=[[5+5+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Lightning damage, [the spell bounces to another target!](`%{@{character_name}|Chaos-Bolt})[ ](#" hidden null=)
}} {{[22]=[[4+6+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Force or Poison damage[ ](#" hidden null=)
}} {{[23]=[[3+7+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Fire or Psychic damage[ ](#" hidden null=)
}} {{[24]=[[2+8+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Cold or Acid damage[ ](#" hidden null=)
}} {{[25]=[[5+6+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Lightning or Poison damage[ ](#" hidden null=)
}} {{[26]=[[4+7+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Force or Psychic damage[ ](#" hidden null=)
}} {{[27]=[[3+8+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Fire or Thunder damage[ ](#" hidden null=)
}} {{[28]=[[6+6+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Poison damage, [the spell bounces to another target!](`%{@{character_name}|Chaos-Bolt})[ ](#" hidden null=)
}} {{[29]=[[5+7+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Lightning or Psychic damage[ ](#" hidden null=)
}} {{[30]=[[4+8+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Force or Thunder damage[ ](#" hidden null=)
}} {{[31]=[[6+7+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Poison or Psychic damage[ ](#" hidden null=)
}} {{[32]=[[5+8+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Lightning or Thunder damage[ ](#" hidden null=)
}} {{[33]=[[7+7+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Psychic damage, [the spell bounces to another target!](`%{@{character_name}|Chaos-Bolt})[ ](#" hidden null=)
}} {{[34]=[[6+8+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Poison or Thunder damage[ ](#" hidden null=)
}} {{[35]=[[7+8+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Psychic or Thunder damage[ ](#" hidden null=)
}} {{[36]=[[8+8+(?{spell level|1|2|3|4|5|6|7|8|9}-1)d6 ]] Thunder damage, [the spell bounces to another target!](`%{@{character_name}|Chaos-Bolt})[ ](#" hidden null=)
}} {{[[[{1,2,4,5,7,9,11,12,14,16,18,20,22,23,25,27,29,31,33,35,37,38,40,42,44,46,48,50,51,53,55,57,59,60,62,64}<[[1d64]] -1]]]=[ ](#)
}}
This is, in truth, a very complex problem that might be better resolved with scripts, but this is a working solution. If you want to access it from the sheet directly, you can make a custom attack on the sheet, check off attack and damage (to disable the queries and extra rolls), and simply add this to the description field:
}} [[1/0]]
%{edit your character name here|Chaos-Bolt}
[[1/0]]